Class: ODDB::Drugs::Part
Constant Summary
Constants included from OddbUri
Instance Attribute Summary collapse
-
#multi ⇒ Object
A partial package can be described as e.g.
-
#quantity ⇒ Object
A partial package can be described as e.g.
-
#size ⇒ Object
Returns the value of attribute size.
-
#unit ⇒ Object
A partial package can be described as e.g.
Instance Method Summary collapse
- #comparable_size ⇒ Object
-
#initialize ⇒ Part
constructor
A new instance of Part.
- #to_s(language = :de) ⇒ Object
Methods inherited from Model
#__odba_delete__, #__odba_save__, _serializables, belongs_to, connections, connector, connectors, #data_origin, #data_origins, delegates, #delete, find_by_uid, has_many, is_coded, m10l_document, multilingual, #odba_serializables, #oid, on_delete, on_save, predicates, #save, #saved?, serializables, serialize, singular
Methods included from ODBA::Persistable
Methods included from Yaml
append_features, #to_yaml_properties
Methods included from OddbUri
#to_yaml, #to_yaml_map, #to_yaml_type
Constructor Details
#initialize ⇒ Part
Returns a new instance of Part.
21 22 23 24 |
# File 'lib/oddb/drugs/part.rb', line 21 def initialize super @size = 1 end |
Instance Attribute Details
#multi ⇒ Object
A partial package can be described as e.g.
10 x 5 Ampoules of 20 ml
^----------------------- :multi - Numeric
^------------------- :size - Numeric
^------------ :unit - Unit (a multilingual)
^---- :quantity - Dose
19 20 21 |
# File 'lib/oddb/drugs/part.rb', line 19 def multi @multi end |
#quantity ⇒ Object
A partial package can be described as e.g.
10 x 5 Ampoules of 20 ml
^----------------------- :multi - Numeric
^------------------- :size - Numeric
^------------ :unit - Unit (a multilingual)
^---- :quantity - Dose
19 20 21 |
# File 'lib/oddb/drugs/part.rb', line 19 def quantity @quantity end |
#size ⇒ Object
Returns the value of attribute size.
20 21 22 |
# File 'lib/oddb/drugs/part.rb', line 20 def size @size end |
#unit ⇒ Object
A partial package can be described as e.g.
10 x 5 Ampoules of 20 ml
^----------------------- :multi - Numeric
^------------------- :size - Numeric
^------------ :unit - Unit (a multilingual)
^---- :quantity - Dose
19 20 21 |
# File 'lib/oddb/drugs/part.rb', line 19 def unit @unit end |
Instance Method Details
#comparable_size ⇒ Object
25 26 27 |
# File 'lib/oddb/drugs/part.rb', line 25 def comparable_size (@quantity || Dose.new(1)) * (@size || 1) * (@multi || 1) end |
#to_s(language = :de) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/oddb/drugs/part.rb', line 36 def to_s(language=:de) parts = [] multi = @multi.to_i if(multi > 1) parts.push multi, 'x' end size = @size.to_i if(size > 1) parts.push(size) end if(unit = @unit) parts.push(unit.name.send(language)) end if(quantity = @quantity) parts.push 'à', quantity end parts.join(' ') end |