Class: Liquid2::TableRow

Inherits:
Object
  • Object
show all
Defined in:
lib/liquid2/nodes/tags/tablerow.rb

Overview

tablerow loop helper variables.

Constant Summary collapse

KEYS =

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#colObject (readonly)

Returns the value of attribute col.



79
80
81
# File 'lib/liquid2/nodes/tags/tablerow.rb', line 79

def col
  @col
end

#lengthObject (readonly)

Returns the value of attribute length.



79
80
81
# File 'lib/liquid2/nodes/tags/tablerow.rb', line 79

def length
  @length
end

#nameObject (readonly)

Returns the value of attribute name.



79
80
81
# File 'lib/liquid2/nodes/tags/tablerow.rb', line 79

def name
  @name
end

#rowObject (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

#col0Object



139
# File 'lib/liquid2/nodes/tags/tablerow.rb', line 139

def col0 = @col - 1

#col_firstObject



140
# File 'lib/liquid2/nodes/tags/tablerow.rb', line 140

def col_first = @col == 1

#col_lastObject



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

#firstObject



137
# File 'lib/liquid2/nodes/tags/tablerow.rb', line 137

def first = @index.zero?

#indexObject



133
# File 'lib/liquid2/nodes/tags/tablerow.rb', line 133

def index = @index + 1

#index0Object



134
# File 'lib/liquid2/nodes/tags/tablerow.rb', line 134

def index0 = @index

#key?(key) ⇒ Boolean

Returns:

  • (Boolean)


106
107
108
# File 'lib/liquid2/nodes/tags/tablerow.rb', line 106

def key?(key)
  KEYS.member?(key)
end

#lastObject



138
# File 'lib/liquid2/nodes/tags/tablerow.rb', line 138

def last = @index == @length - 1

#nextObject



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

#rindexObject



135
# File 'lib/liquid2/nodes/tags/tablerow.rb', line 135

def rindex = @length - @index

#rindex0Object



136
# File 'lib/liquid2/nodes/tags/tablerow.rb', line 136

def rindex0 = @length - @index - 1