Class: Amcss::Html::Attribute

Inherits:
Object
  • Object
show all
Defined in:
lib/amcss/html/attribute.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, value) ⇒ Attribute

Returns a new instance of Attribute.



16
17
18
# File 'lib/amcss/html/attribute.rb', line 16

def initialize(name, value)
  @name, @value = name, value
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



3
4
5
# File 'lib/amcss/html/attribute.rb', line 3

def name
  @name
end

#valueObject (readonly)

Returns the value of attribute value.



3
4
5
# File 'lib/amcss/html/attribute.rb', line 3

def value
  @value
end

Class Method Details

.from(modüle, *variations_or_traits) ⇒ Object



6
7
8
# File 'lib/amcss/html/attribute.rb', line 6

def from(modüle, *variations_or_traits)
  new("#{namespace}-#{modüle}", variations_or_traits.compact.map(&:to_s).join(' '))
end

Instance Method Details

#to_hashObject



20
21
22
# File 'lib/amcss/html/attribute.rb', line 20

def to_hash
  {name => value}
end

#to_sObject



24
25
26
# File 'lib/amcss/html/attribute.rb', line 24

def to_s
  %Q{#{name}="#{value}"}
end