Class: Liquid2::TableRow
- Inherits:
-
Object
- Object
- Liquid2::TableRow
- Defined in:
- lib/liquid2/nodes/tags/tablerow.rb
Overview
tablerow loop helper variables.
Constant Summary collapse
- KEYS =
Instance Attribute Summary collapse
-
#col ⇒ Object
readonly
Returns the value of attribute col.
-
#length ⇒ Object
readonly
Returns the value of attribute length.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#row ⇒ Object
readonly
Returns the value of attribute row.
Instance Method Summary collapse
- #[](key) ⇒ Object
- #col0 ⇒ Object
- #col_first ⇒ Object
- #col_last ⇒ Object
- #fetch(key, default = :undefined) ⇒ Object
- #first ⇒ Object
- #index ⇒ Object
- #index0 ⇒ Object
-
#initialize(name, length, cols) ⇒ TableRow
constructor
A new instance of TableRow.
- #key?(key) ⇒ Boolean
- #last ⇒ Object
- #next ⇒ Object
- #rindex ⇒ Object
- #rindex0 ⇒ Object
Constructor Details
#initialize(name, length, cols) ⇒ TableRow
Returns a new instance of TableRow.
97 98 99 100 101 102 103 104 |
# File 'lib/liquid2/nodes/tags/tablerow.rb', line 97 def initialize(name, length, cols) @name = name @length = length @cols = cols @index = -1 @row = 1 @col = 0 end |
Instance Attribute Details
#col ⇒ Object (readonly)
Returns the value of attribute col.
79 80 81 |
# File 'lib/liquid2/nodes/tags/tablerow.rb', line 79 def col @col end |
#length ⇒ Object (readonly)
Returns the value of attribute length.
79 80 81 |
# File 'lib/liquid2/nodes/tags/tablerow.rb', line 79 def length @length end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
79 80 81 |
# File 'lib/liquid2/nodes/tags/tablerow.rb', line 79 def name @name end |
#row ⇒ Object (readonly)
Returns the value of attribute row.
79 80 81 |
# File 'lib/liquid2/nodes/tags/tablerow.rb', line 79 def row @row end |
Instance Method Details
#[](key) ⇒ Object
110 111 112 |
# File 'lib/liquid2/nodes/tags/tablerow.rb', line 110 def [](key) send(key) if KEYS.member?(key) end |
#col0 ⇒ Object
139 |
# File 'lib/liquid2/nodes/tags/tablerow.rb', line 139 def col0 = @col - 1 |
#col_first ⇒ Object
140 |
# File 'lib/liquid2/nodes/tags/tablerow.rb', line 140 def col_first = @col == 1 |
#col_last ⇒ Object
141 |
# File 'lib/liquid2/nodes/tags/tablerow.rb', line 141 def col_last = @col == @cols |
#fetch(key, default = :undefined) ⇒ Object
114 115 116 117 118 119 120 |
# File 'lib/liquid2/nodes/tags/tablerow.rb', line 114 def fetch(key, default = :undefined) if KEYS.member?(key) send(key) else default end end |
#first ⇒ Object
137 |
# File 'lib/liquid2/nodes/tags/tablerow.rb', line 137 def first = @index.zero? |
#index ⇒ Object
133 |
# File 'lib/liquid2/nodes/tags/tablerow.rb', line 133 def index = @index + 1 |
#index0 ⇒ Object
134 |
# File 'lib/liquid2/nodes/tags/tablerow.rb', line 134 def index0 = @index |
#key?(key) ⇒ Boolean
106 107 108 |
# File 'lib/liquid2/nodes/tags/tablerow.rb', line 106 def key?(key) KEYS.member?(key) end |
#last ⇒ Object
138 |
# File 'lib/liquid2/nodes/tags/tablerow.rb', line 138 def last = @index == @length - 1 |
#next ⇒ Object
122 123 124 125 126 127 128 129 130 131 |
# File 'lib/liquid2/nodes/tags/tablerow.rb', line 122 def next @index += 1 if @col == @cols @col = 1 @row += 1 else @col += 1 end end |
#rindex ⇒ Object
135 |
# File 'lib/liquid2/nodes/tags/tablerow.rb', line 135 def rindex = @length - @index |
#rindex0 ⇒ Object
136 |
# File 'lib/liquid2/nodes/tags/tablerow.rb', line 136 def rindex0 = @length - @index - 1 |