Class: Deep::Hash::Struct::Dashboard::Table::Tr
- Inherits:
-
Object
- Object
- Deep::Hash::Struct::Dashboard::Table::Tr
- Includes:
- PP::Dashboard::Table::Tr
- Defined in:
- lib/deep/hash/struct/dashboard/table/tr.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
Returns the value of attribute body.
-
#header ⇒ Object
Returns the value of attribute header.
-
#options ⇒ Object
Returns the value of attribute options.
-
#side ⇒ Object
Returns the value of attribute side.
Instance Method Summary collapse
-
#initialize(header, body, side, options = {}) ⇒ Tr
constructor
A new instance of Tr.
- #td(value = nil) ⇒ Object
- #th(value = nil) ⇒ Object
Methods included from PP::Dashboard::Table::Tr
Constructor Details
#initialize(header, body, side, options = {}) ⇒ Tr
Returns a new instance of Tr.
11 12 13 14 15 16 |
# File 'lib/deep/hash/struct/dashboard/table/tr.rb', line 11 def initialize(header, body, side, = {}) @header = header @body = body @side = side @options = end |
Instance Attribute Details
#body ⇒ Object
Returns the value of attribute body.
9 10 11 |
# File 'lib/deep/hash/struct/dashboard/table/tr.rb', line 9 def body @body end |
#header ⇒ Object
Returns the value of attribute header.
9 10 11 |
# File 'lib/deep/hash/struct/dashboard/table/tr.rb', line 9 def header @header end |
#options ⇒ Object
Returns the value of attribute options.
9 10 11 |
# File 'lib/deep/hash/struct/dashboard/table/tr.rb', line 9 def @options end |
#side ⇒ Object
Returns the value of attribute side.
9 10 11 |
# File 'lib/deep/hash/struct/dashboard/table/tr.rb', line 9 def side @side end |
Instance Method Details
#td(value = nil) ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/deep/hash/struct/dashboard/table/tr.rb', line 48 def td(value = nil) hash = {} if !value.is_a?(Array) && value.respond_to?(:each) if value.has_key?(:key) && value.has_key?(:value) hash[value[:key]] = value[:value] else value.each do |k, v| hash[k] = v end end else i = body.count + 1 hash["key_#{i}"] = value end if [:side] hash.each do |k, v| body[k][side.keys[[:b_index]]] = v end else body.merge! hash end end |
#th(value = nil) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/deep/hash/struct/dashboard/table/tr.rb', line 18 def th(value = nil) hash = {} if !value.is_a?(Array) && value.respond_to?(:each) if value.has_key?(:key) && value.has_key?(:value) hash[value[:key]] = value[:value] else value.each do |k, v| hash[k] = v end end else i = if [:side] side.count + 1 elsif [:matrix] header.count else header.count + 1 end hash["key_#{i}"] = value end if [:side] side.merge! hash else header.merge! hash end value end |