Class: TmxParser::Unit
- Inherits:
-
Object
- Object
- TmxParser::Unit
- Defined in:
- lib/tmx-parser/elements.rb
Instance Attribute Summary collapse
-
#properties ⇒ Object
readonly
Returns the value of attribute properties.
-
#segtype ⇒ Object
readonly
Returns the value of attribute segtype.
-
#tuid ⇒ Object
readonly
Returns the value of attribute tuid.
-
#variants ⇒ Object
readonly
Returns the value of attribute variants.
Instance Method Summary collapse
- #==(other_unit) ⇒ Object
- #copy ⇒ Object
-
#initialize(tuid, segtype) ⇒ Unit
constructor
A new instance of Unit.
Constructor Details
#initialize(tuid, segtype) ⇒ Unit
Returns a new instance of Unit.
8 9 10 11 12 13 |
# File 'lib/tmx-parser/elements.rb', line 8 def initialize(tuid, segtype) @tuid = tuid @segtype = segtype @properties = {} @variants = [] end |
Instance Attribute Details
#properties ⇒ Object (readonly)
Returns the value of attribute properties.
6 7 8 |
# File 'lib/tmx-parser/elements.rb', line 6 def properties @properties end |
#segtype ⇒ Object (readonly)
Returns the value of attribute segtype.
6 7 8 |
# File 'lib/tmx-parser/elements.rb', line 6 def segtype @segtype end |
#tuid ⇒ Object (readonly)
Returns the value of attribute tuid.
6 7 8 |
# File 'lib/tmx-parser/elements.rb', line 6 def tuid @tuid end |
#variants ⇒ Object (readonly)
Returns the value of attribute variants.
6 7 8 |
# File 'lib/tmx-parser/elements.rb', line 6 def variants @variants end |
Instance Method Details
#==(other_unit) ⇒ Object
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/tmx-parser/elements.rb', line 24 def ==(other_unit) tuid == other_unit.tuid && segtype == other_unit.segtype && variants.each_with_index.all? do |v, idx| other_unit.variants[idx] == v end && properties.each_with_index.all? do |(key, prop_val), idx| other_unit.properties[key] == prop_val end end |
#copy ⇒ Object
15 16 17 18 19 20 21 22 |
# File 'lib/tmx-parser/elements.rb', line 15 def copy self.class.new(tuid.dup, segtype.dup).tap do |new_unit| new_unit.variants.concat(variants.map(&:copy)) properties.each do |key, property_value| new_unit.properties[key] = property_value.copy end end end |