Class: Griddle::Style

Inherits:
Object
  • Object
show all
Defined in:
lib/griddle/style.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, definition, attachment) ⇒ Style

Returns a new instance of Style.



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/griddle/style.rb', line 6

def initialize(name, definition, attachment)
  @name = name
  @attachment = attachment
  @definition = case 
  when definition.is_a?(String)
    {
      :geometry => definition
    }
  when definition.is_a?(Array)
    raise "Don't send an array to Style"
  else
    raise "Definition must be a type of String, Array, or Hash" unless definition.is_a?(Hash)
    {
      :geometry => definition[:geometry]
    }
  end
  
end

Instance Attribute Details

#attachmentObject

Returns the value of attribute attachment.



4
5
6
# File 'lib/griddle/style.rb', line 4

def attachment
  @attachment
end

#definitionObject

Returns the value of attribute definition.



4
5
6
# File 'lib/griddle/style.rb', line 4

def definition
  @definition
end

#nameObject

Returns the value of attribute name.



4
5
6
# File 'lib/griddle/style.rb', line 4

def name
  @name
end

Instance Method Details

#[](key) ⇒ Object



25
26
27
28
# File 'lib/griddle/style.rb', line 25

def [](key)
  return nil unless respond_to? key
  send(key)
end

#geometryObject



34
35
36
# File 'lib/griddle/style.rb', line 34

def geometry
  @definition[:geometry]
end