Class: Bulldog::Style
- Inherits:
-
Object
- Object
- Bulldog::Style
- Defined in:
- lib/bulldog/style.rb
Overview
Represents a style to generate.
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
-
#dimensions ⇒ Object
readonly
The [width, height] specified by :size, or nil if there is no :size.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
-
#==(other) ⇒ Object
Return true if the argument is a Style with the same name and attributes.
-
#[]=(name, value) ⇒ Object
Set the value of the given style attribute.
-
#filled? ⇒ Boolean
Return true if :filled is true, false otherwise.
-
#initialize(name, attributes = {}) ⇒ Style
constructor
A new instance of Style.
- #inspect ⇒ Object
Constructor Details
#initialize(name, attributes = {}) ⇒ Style
Returns a new instance of Style.
6 7 8 9 10 |
# File 'lib/bulldog/style.rb', line 6 def initialize(name, attributes={}) @name = name @attributes = attributes set_dimensions(attributes[:size]) end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
12 13 14 |
# File 'lib/bulldog/style.rb', line 12 def attributes @attributes end |
#dimensions ⇒ Object (readonly)
The [width, height] specified by :size, or nil if there is no :size.
48 49 50 |
# File 'lib/bulldog/style.rb', line 48 def dimensions @dimensions end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
12 13 14 |
# File 'lib/bulldog/style.rb', line 12 def name @name end |
Instance Method Details
#==(other) ⇒ Object
Return true if the argument is a Style with the same name and attributes.
33 34 35 36 37 |
# File 'lib/bulldog/style.rb', line 33 def ==(other) other.is_a?(self.class) && name == other.name && attributes == other.attributes end |
#[]=(name, value) ⇒ Object
Set the value of the given style attribute.
22 23 24 25 26 27 |
# File 'lib/bulldog/style.rb', line 22 def []=(name, value) if name == :size set_dimensions(value) end attributes[name] = value end |
#filled? ⇒ Boolean
Return true if :filled is true, false otherwise.
53 54 55 |
# File 'lib/bulldog/style.rb', line 53 def filled? !!self[:filled] end |
#inspect ⇒ Object
39 40 41 |
# File 'lib/bulldog/style.rb', line 39 def inspect "#<Style #{name.inspect} #{attributes.inspect}>" end |