Class: Griddle::Style
- Inherits:
-
Object
- Object
- Griddle::Style
- Defined in:
- lib/griddle/style.rb
Instance Attribute Summary collapse
-
#attachment ⇒ Object
Returns the value of attribute attachment.
-
#definition ⇒ Object
Returns the value of attribute definition.
-
#name ⇒ Object
Returns the value of attribute name.
Instance Method Summary collapse
- #[](key) ⇒ Object
- #geometry ⇒ Object
-
#initialize(name, definition, attachment) ⇒ Style
constructor
A new instance of Style.
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, ) @name = name @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
#attachment ⇒ Object
Returns the value of attribute attachment.
4 5 6 |
# File 'lib/griddle/style.rb', line 4 def @attachment end |
#definition ⇒ Object
Returns the value of attribute definition.
4 5 6 |
# File 'lib/griddle/style.rb', line 4 def definition @definition end |
#name ⇒ Object
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 |
#geometry ⇒ Object
34 35 36 |
# File 'lib/griddle/style.rb', line 34 def geometry @definition[:geometry] end |