Class: HQMF::Ratio
- Inherits:
-
Object
- Object
- HQMF::Ratio
- Includes:
- Conversion::Utilities
- Defined in:
- lib/hqmf-model/types.rb
Instance Attribute Summary collapse
-
#denominator ⇒ Object
Returns the value of attribute denominator.
-
#numerator ⇒ Object
Returns the value of attribute numerator.
-
#type ⇒ Object
Returns the value of attribute type.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object
- #denominator? ⇒ Boolean
-
#initialize(type, numerator, denominator) ⇒ Ratio
constructor
A new instance of Ratio.
- #numerator? ⇒ Boolean
- #to_json ⇒ Object
Methods included from Conversion::Utilities
#build_hash, #check_equality, #json_array, #openstruct_to_json
Constructor Details
#initialize(type, numerator, denominator) ⇒ Ratio
Returns a new instance of Ratio.
464 465 466 467 468 |
# File 'lib/hqmf-model/types.rb', line 464 def initialize(type, numerator, denominator) @type = type || 'RT' @numerator = numerator @denominator = denominator end |
Instance Attribute Details
#denominator ⇒ Object
Returns the value of attribute denominator.
459 460 461 |
# File 'lib/hqmf-model/types.rb', line 459 def denominator @denominator end |
#numerator ⇒ Object
Returns the value of attribute numerator.
459 460 461 |
# File 'lib/hqmf-model/types.rb', line 459 def numerator @numerator end |
#type ⇒ Object
Returns the value of attribute type.
459 460 461 |
# File 'lib/hqmf-model/types.rb', line 459 def type @type end |
Class Method Details
.from_json(json) ⇒ Object
470 471 472 473 474 475 |
# File 'lib/hqmf-model/types.rb', line 470 def self.from_json(json) type = json["type"] if json["type"] numerator = json["numerator"] if json["numerator"] denominator = json["denominator"] if json["denominator"] HQMF::Ratio.new(type, numerator, denominator) end |
Instance Method Details
#==(other) ⇒ Object
489 490 491 |
# File 'lib/hqmf-model/types.rb', line 489 def ==(other) check_equality(self, other) end |
#denominator? ⇒ Boolean
481 482 483 |
# File 'lib/hqmf-model/types.rb', line 481 def denominator? @denominator end |
#numerator? ⇒ Boolean
477 478 479 |
# File 'lib/hqmf-model/types.rb', line 477 def numerator? @numerator end |
#to_json ⇒ Object
485 486 487 |
# File 'lib/hqmf-model/types.rb', line 485 def to_json build_hash(self, [:type, :numerator, :denominator]) end |