Class: Numerals::ContextConversion

Inherits:
Object
  • Object
show all
Defined in:
lib/numerals/conversions/context_conversion.rb

Overview

Base class for Conversions of type with context

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(context_or_type, options = {}) ⇒ ContextConversion

Returns a new instance of ContextConversion.



7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/numerals/conversions/context_conversion.rb', line 7

def initialize(context_or_type, options={})
  if Class === context_or_type && context_or_type.respond_to?(:context)
    @type = context_or_type
    @context = @type.context
  elsif context_or_type.respond_to?(:num_class)
    @context = context_or_type
    @type = @context.num_class
  else
    raise "Invalid Conversion definition"
  end
  self.input_rounding = options[:input_rounding]
end

Instance Attribute Details

#contextObject (readonly)

Returns the value of attribute context.



20
21
22
# File 'lib/numerals/conversions/context_conversion.rb', line 20

def context
  @context
end

#input_roundingObject

Returns the value of attribute input_rounding.



20
21
22
# File 'lib/numerals/conversions/context_conversion.rb', line 20

def input_rounding
  @input_rounding
end

#typeObject (readonly)

Returns the value of attribute type.



20
21
22
# File 'lib/numerals/conversions/context_conversion.rb', line 20

def type
  @type
end