Class: Elemac::Property
- Inherits:
-
Object
- Object
- Elemac::Property
- Defined in:
- lib/elemac/property.rb
Instance Method Summary collapse
- #get_address ⇒ Object
- #get_type(type) ⇒ Object
-
#initialize(address:, offset: 0, type: :int) ⇒ Property
constructor
A new instance of Property.
- #to_s ⇒ Object
Constructor Details
#initialize(address:, offset: 0, type: :int) ⇒ Property
Returns a new instance of Property.
3 4 5 6 7 |
# File 'lib/elemac/property.rb', line 3 def initialize(address:, offset: 0, type: :int) @address = address @offset = offset @type = type end |
Instance Method Details
#get_address ⇒ Object
20 21 22 |
# File 'lib/elemac/property.rb', line 20 def get_address (@offset + @address).to_s(16).upcase.rjust(3, '0') end |
#get_type(type) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/elemac/property.rb', line 8 def get_type(type) case(type) when :char # 1 byte 'r0' when :short # 2 bytes 'r1' when :int # 3 bytes 'r2' when :long # 4 bytes 'r3' end end |
#to_s ⇒ Object
23 24 25 |
# File 'lib/elemac/property.rb', line 23 def to_s "#{get_type(@type)}#{get_address}" end |