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.
-
#entries ⇒ Object
readonly
Returns the value of attribute entries.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Class Method Summary collapse
Instance Method Summary collapse
- #[](key) ⇒ Object
-
#initialize(name, entries = {}) ⇒ Table
constructor
A new instance of Table.
- #to_h ⇒ Object
Constructor Details
#initialize(name, entries = {}) ⇒ Table
Returns a new instance of Table.
14 15 16 17 18 19 20 |
# File 'lib/looker/table.rb', line 14 def initialize(name, entries={}) @name = name.to_s.strip.freeze @constant_name = self.class.constant_name(@name).freeze @entries = entries.dup.freeze @dict = entries.invert.merge(entries).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 |
#entries ⇒ Object (readonly)
Returns the value of attribute entries.
8 9 10 |
# File 'lib/looker/table.rb', line 8 def entries @entries end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
8 9 10 |
# File 'lib/looker/table.rb', line 8 def name @name 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 entries end |