Class: Grid
- Inherits:
-
RKit::Grid::Base
- Object
- RKit::Grid::Base
- Grid
- Defined in:
- lib/r_kit/grid/base/grid.rb
Instance Attribute Summary collapse
-
#collection ⇒ Object
Returns the value of attribute collection.
Attributes inherited from RKit::Grid::Base
Class Method Summary collapse
Instance Method Summary collapse
- #_attributes ⇒ Object
- #_tag ⇒ Object
- #capture ⇒ Object
- #flex(&block) ⇒ Object
-
#initialize(collection, &block) ⇒ Grid
constructor
A new instance of Grid.
- #items(value, &block) ⇒ Object
- #required_bindings ⇒ Object
Methods inherited from RKit::Grid::Base
Constructor Details
#initialize(collection, &block) ⇒ Grid
Returns a new instance of Grid.
18 19 20 21 22 23 24 25 |
# File 'lib/r_kit/grid/base/grid.rb', line 18 def initialize collection, &block @collection = collection @_binding = RKit::Grid::Binding.new @_binding.block = block super @_binding end |
Instance Attribute Details
#collection ⇒ Object
Returns the value of attribute collection.
16 17 18 |
# File 'lib/r_kit/grid/base/grid.rb', line 16 def collection @collection end |
Class Method Details
.binding_accessor(name) ⇒ Object
40 41 42 43 44 45 46 47 |
# File 'lib/r_kit/grid/base/grid.rb', line 40 def binding_accessor name define_method name do |value, &block| _binding.block = block if block _binding.send "#{ name }=", value self end end |
.try_convert(object, &block) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 |
# File 'lib/r_kit/grid/base/grid.rb', line 3 def self.try_convert object, &block if object.kind_of? RKit::Grid::Base object elsif object.respond_to? :to_grid object.to_grid &block else RKit::Grid::Base::Grid.new Array.wrap(object), &block end end |
Instance Method Details
#_attributes ⇒ Object
70 71 72 |
# File 'lib/r_kit/grid/base/grid.rb', line 70 def _attributes _binding.attributes end |
#_tag ⇒ Object
66 67 68 |
# File 'lib/r_kit/grid/base/grid.rb', line 66 def _tag :div end |
#capture ⇒ Object
74 75 76 77 78 79 |
# File 'lib/r_kit/grid/base/grid.rb', line 74 def capture collection.map do |object| GridCol.new(object, binding: _binding).to_s end .reduce(:safe_concat) end |
#flex(&block) ⇒ Object
56 57 58 |
# File 'lib/r_kit/grid/base/grid.rb', line 56 def flex &block attributes class: 'grid-flex', &block end |
#items(value, &block) ⇒ Object
60 61 62 |
# File 'lib/r_kit/grid/base/grid.rb', line 60 def items value, &block attributes class: "grid-items-#{ value }", &block end |
#required_bindings ⇒ Object
27 28 29 30 31 32 33 34 35 36 |
# File 'lib/r_kit/grid/base/grid.rb', line 27 def required_bindings # TODO: change config to min-col-size # TODO: col size adapts to collection size, but not below min-col-size { col_size: RKit::Grid.config.col_size, attributes: { class: :grid } } end |