Sha256: c82c530eff8d5a12a43f1129f097bc34ac7b56153ebebb4db114d4ee8b386b47
Contents?: true
Size: 1.3 KB
Versions: 3
Compression:
Stored size: 1.3 KB
Contents
# frozen_string_literal: true require 'ruby_jard/layout' require 'ruby_jard/templates/layout_template' require 'ruby_jard/templates/screen_template' require 'ruby_jard/layout_picker' require 'ruby_jard/layout_calculator' module RubyJard ## # Layouts registry. class Layouts class << self extend Forwardable def_delegators :instance, :fallback_layout, :add_layout, :[], :get, :each def instance @instance ||= new end end attr_reader :fallback_layout def initialize(fallback_layout = RubyJard::Layouts::WideLayout) @layout_registry = {} @fallback_layout = fallback_layout end def add_layout(name, layout_class) unless layout_class.is_a?(RubyJard::Templates::LayoutTemplate) raise RubyJard::Error, "#{layout_class} must be a #{RubyJard::Templates::LayoutTemplate}" end @layout_registry[name] = layout_class end def [](name) @layout_registry[name.to_s.strip] end alias_method :get, :[] def each(&block) @layout_registry.each(&block) end end end # Registering order is also priority when picking layout require 'ruby_jard/layouts/wide_layout' require 'ruby_jard/layouts/narrow_vertical_layout' require 'ruby_jard/layouts/narrow_horizontal_layout' require 'ruby_jard/layouts/tiny_layout'
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
ruby_jard-0.3.1 | lib/ruby_jard/layouts.rb |
ruby_jard-0.3.0 | lib/ruby_jard/layouts.rb |
ruby_jard-0.2.3 | lib/ruby_jard/layouts.rb |