Class: Gammo::Attribute

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

Overview

Class for representing an attribute.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key:, value:, namespace: nil, owner_element: nil) ⇒ Attribute

Constructs an attribute with the key-value pair.

Parameters:

  • key (String)
  • value (String)
  • namespace (String) (defaults to: nil)
  • owner_element (Gammo::Element) (defaults to: nil)


15
16
17
18
19
20
# File 'lib/gammo/attribute.rb', line 15

def initialize(key:, value:, namespace: nil, owner_element: nil)
  @key           = key
  @value         = value
  @namespace     = namespace
  @owner_element = owner_element
end

Instance Attribute Details

#keyObject

Returns the value of attribute key.



4
5
6
# File 'lib/gammo/attribute.rb', line 4

def key
  @key
end

#namespaceObject

Returns the value of attribute namespace.



4
5
6
# File 'lib/gammo/attribute.rb', line 4

def namespace
  @namespace
end

#valueObject

Returns the value of attribute value.



4
5
6
# File 'lib/gammo/attribute.rb', line 4

def value
  @value
end

Instance Method Details

#to_sObject



22
23
24
# File 'lib/gammo/attribute.rb', line 22

def to_s
  "<Gammo::Attribute #{key}='#{value}'>"
end