Class: Looker::Table

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
Enumerable
Defined in:
lib/looker/table.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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_nameObject (readonly)

Returns the value of attribute constant_name.



8
9
10
# File 'lib/looker/table.rb', line 8

def constant_name
  @constant_name
end

#entriesObject (readonly)

Returns the value of attribute entries.



8
9
10
# File 'lib/looker/table.rb', line 8

def entries
  @entries
end

#nameObject (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_hObject



26
27
28
# File 'lib/looker/table.rb', line 26

def to_h
  entries
end