Class: Karabiner::Property

Inherits:
Object
  • Object
show all
Includes:
XmlTree
Defined in:
lib/karabiner/property.rb

Direct Known Subclasses

Remap

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from XmlTree

#add_child, #search_childs

Constructor Details

#initialize(attr, value, options = {}) ⇒ Property

Returns a new instance of Property.



4
5
6
7
8
# File 'lib/karabiner/property.rb', line 4

def initialize(attr, value, options = {})
  @attr = attr.to_s
  @value = value
  @options = options
end

Instance Attribute Details

#attrObject

Returns the value of attribute attr.



9
10
11
# File 'lib/karabiner/property.rb', line 9

def attr
  @attr
end

#valueObject

Returns the value of attribute value.



9
10
11
# File 'lib/karabiner/property.rb', line 9

def value
  @value
end

Instance Method Details

#to_xmlObject



11
12
13
14
# File 'lib/karabiner/property.rb', line 11

def to_xml
  open_tag = @options.map { |a, v| "#{a}=\"#{v}\"" }.unshift(attr).join(" ")
  "<#{open_tag}>#{value}</#{attr}>"
end