Class: EEML::Unit

Inherits:
Object
  • Object
show all
Defined in:
lib/eeml/unit.rb

Overview

An class representing a unit or measurement. Can be added to EEML::Data objects

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(unit_name, options = {}) ⇒ Unit

Create a new EEML::Unit item.



8
9
10
11
12
# File 'lib/eeml/unit.rb', line 8

def initialize(unit_name, options = {})
  @name = unit_name
  @symbol = options[:symbol]
  set_type(options[:type])
end

Instance Attribute Details

#nameObject

Name of the unit (e.g. “metre”)



15
16
17
# File 'lib/eeml/unit.rb', line 15

def name
  @name
end

#symbolObject

Symbol for the unit (e.g. “m”)



18
19
20
# File 'lib/eeml/unit.rb', line 18

def symbol
  @symbol
end

Instance Method Details

#typeObject

Get the type of the unit



21
22
23
# File 'lib/eeml/unit.rb', line 21

def type
  @type
end

#type=(unit_type) ⇒ Object

Set the type of the unit - must be one of :basicSI, :derivedSI, :conversionBasedUnits, :derivedUnits or :contextDependentUnits



26
27
28
# File 'lib/eeml/unit.rb', line 26

def type=(unit_type)
  set_type(unit_type)
end