Class: Looker::Table
- Inherits:
-
Object
- Object
- Looker::Table
- Extended by:
- Forwardable
- Includes:
- Enumerable
- Defined in:
- lib/looker/table.rb
Instance Attribute Summary collapse
-
#constant_name ⇒ Object
readonly
Returns the value of attribute constant_name.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#rows ⇒ Object
readonly
Returns the value of attribute rows.
Class Method Summary collapse
Instance Method Summary collapse
- #[](key) ⇒ Object
-
#initialize(name, rows = {}) ⇒ Table
constructor
A new instance of Table.
- #to_h ⇒ Object
Constructor Details
#initialize(name, rows = {}) ⇒ Table
Returns a new instance of Table.
14 15 16 17 18 19 20 |
# File 'lib/looker/table.rb', line 14 def initialize(name, rows={}) @name = name.to_s.strip.freeze @constant_name = self.class.constant_name(@name).freeze @rows = rows.dup.freeze @dict = rows.invert.merge(rows).freeze freeze end |
Instance Attribute Details
#constant_name ⇒ Object (readonly)
Returns the value of attribute constant_name.
8 9 10 |
# File 'lib/looker/table.rb', line 8 def constant_name @constant_name end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
8 9 10 |
# File 'lib/looker/table.rb', line 8 def name @name end |
#rows ⇒ Object (readonly)
Returns the value of attribute rows.
8 9 10 |
# File 'lib/looker/table.rb', line 8 def rows @rows end |
Class Method Details
.constant_name(name) ⇒ Object
10 11 12 |
# File 'lib/looker/table.rb', line 10 def self.constant_name(name) name.gsub(/\s/, "_").gsub(/\W/, "").upcase end |
Instance Method Details
#[](key) ⇒ Object
22 23 24 |
# File 'lib/looker/table.rb', line 22 def [](key) dict[key] || dict[key.to_s] || dict[key.to_s.to_sym] end |
#to_h ⇒ Object
26 27 28 |
# File 'lib/looker/table.rb', line 26 def to_h rows end |