Class: Bulldog::Style

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

Overview

Represents a style to generate.

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#attributesObject (readonly)

Returns the value of attribute attributes.



12
13
14
# File 'lib/bulldog/style.rb', line 12

def attributes
  @attributes
end

#dimensionsObject (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

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

Returns:

  • (Boolean)


53
54
55
# File 'lib/bulldog/style.rb', line 53

def filled?
  !!self[:filled]
end

#inspectObject



39
40
41
# File 'lib/bulldog/style.rb', line 39

def inspect
  "#<Style #{name.inspect} #{attributes.inspect}>"
end