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.



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

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.



22
23
24
# File 'lib/numerals/conversions/context_conversion.rb', line 22

def context
  @context
end

#input_roundingObject

Returns the value of attribute input_rounding.



22
23
24
# File 'lib/numerals/conversions/context_conversion.rb', line 22

def input_rounding
  @input_rounding
end

#typeObject (readonly)

Returns the value of attribute type.



22
23
24
# File 'lib/numerals/conversions/context_conversion.rb', line 22

def type
  @type
end