Class: LightCurrencyConverter::Processor
- Inherits:
-
Object
- Object
- LightCurrencyConverter::Processor
- Defined in:
- lib/light_currency_convert/processor.rb
Instance Attribute Summary collapse
-
#amount ⇒ Object
Returns the value of attribute amount.
-
#course ⇒ Object
Returns the value of attribute course.
-
#currencies ⇒ Object
Returns the value of attribute currencies.
-
#from ⇒ Object
Returns the value of attribute from.
-
#to ⇒ Object
Returns the value of attribute to.
Instance Method Summary collapse
- #convert ⇒ Object
-
#initialize(from, to, amount, currecnies) ⇒ Processor
constructor
A new instance of Processor.
- #process ⇒ Object
- #show_course ⇒ Object
Constructor Details
#initialize(from, to, amount, currecnies) ⇒ Processor
Returns a new instance of Processor.
5 6 7 8 9 10 11 |
# File 'lib/light_currency_convert/processor.rb', line 5 def initialize(from, to, amount, currecnies) @from = from @to = to @amount = amount @currecnies = currecnies @course = currecnies.find_currency_course(from, to) end |
Instance Attribute Details
#amount ⇒ Object
Returns the value of attribute amount.
3 4 5 |
# File 'lib/light_currency_convert/processor.rb', line 3 def amount @amount end |
#course ⇒ Object
Returns the value of attribute course.
3 4 5 |
# File 'lib/light_currency_convert/processor.rb', line 3 def course @course end |
#currencies ⇒ Object
Returns the value of attribute currencies.
3 4 5 |
# File 'lib/light_currency_convert/processor.rb', line 3 def currencies @currencies end |
#from ⇒ Object
Returns the value of attribute from.
3 4 5 |
# File 'lib/light_currency_convert/processor.rb', line 3 def from @from end |
#to ⇒ Object
Returns the value of attribute to.
3 4 5 |
# File 'lib/light_currency_convert/processor.rb', line 3 def to @to end |
Instance Method Details
#convert ⇒ Object
19 20 21 22 |
# File 'lib/light_currency_convert/processor.rb', line 19 def convert raise NoCourseFundError unless @course @course.convert(amount, from, to) end |
#process ⇒ Object
13 14 15 16 17 |
# File 'lib/light_currency_convert/processor.rb', line 13 def process amount.nil? ? show_course : convert rescue NoCourseFundError 'No course correlation has been found.' end |
#show_course ⇒ Object
24 25 26 27 |
# File 'lib/light_currency_convert/processor.rb', line 24 def show_course raise NoCourseFundError unless @course @course.to_s end |