Class: Curly::Parser::Component

Inherits:
Object
  • Object
show all
Defined in:
lib/curly/parser.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, identifier = nil, attributes = {}, contexts = []) ⇒ Component

Returns a new instance of Component.



8
9
10
# File 'lib/curly/parser.rb', line 8

def initialize(name, identifier = nil, attributes = {}, contexts = [])
  @name, @identifier, @attributes, @contexts = name, identifier, attributes, contexts
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



6
7
8
# File 'lib/curly/parser.rb', line 6

def attributes
  @attributes
end

#contextsObject (readonly)

Returns the value of attribute contexts.



6
7
8
# File 'lib/curly/parser.rb', line 6

def contexts
  @contexts
end

#identifierObject (readonly)

Returns the value of attribute identifier.



6
7
8
# File 'lib/curly/parser.rb', line 6

def identifier
  @identifier
end

#nameObject (readonly)

Returns the value of attribute name.



6
7
8
# File 'lib/curly/parser.rb', line 6

def name
  @name
end

Instance Method Details

#==(other) ⇒ Object



16
17
18
19
20
21
# File 'lib/curly/parser.rb', line 16

def ==(other)
  other.name == name &&
    other.identifier == identifier &&
    other.attributes == attributes &&
    other.contexts == contexts
end

#to_sObject



12
13
14
# File 'lib/curly/parser.rb', line 12

def to_s
  contexts.map {|c| c + ":" }.join << [name, identifier].compact.join(".")
end

#typeObject



23
24
25
# File 'lib/curly/parser.rb', line 23

def type
  :component
end