Class: TimePricing::Plan
- Inherits:
-
Object
- Object
- TimePricing::Plan
- Defined in:
- lib/time_pricing/plan.rb
Instance Attribute Summary collapse
-
#cost ⇒ Object
readonly
Returns the value of attribute cost.
-
#duration ⇒ Object
readonly
Returns the value of attribute duration.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
-
#initialize(**args) ⇒ Plan
constructor
A new instance of Plan.
- #to_json ⇒ Object
Constructor Details
#initialize(**args) ⇒ Plan
Returns a new instance of Plan.
5 6 7 8 9 10 11 12 13 14 |
# File 'lib/time_pricing/plan.rb', line 5 def initialize(**args) @name = args[:name] @duration = args[:duration] @cost = args[:cost] # validate plan data if !@name || !@duration.is_a?(Integer) || !@cost.is_a?(Integer) raise TimePricing::ParameterMissing.new "Not a valid plan" end end |
Instance Attribute Details
#cost ⇒ Object (readonly)
Returns the value of attribute cost.
3 4 5 |
# File 'lib/time_pricing/plan.rb', line 3 def cost @cost end |
#duration ⇒ Object (readonly)
Returns the value of attribute duration.
3 4 5 |
# File 'lib/time_pricing/plan.rb', line 3 def duration @duration end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/time_pricing/plan.rb', line 3 def name @name end |
Instance Method Details
#to_json ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/time_pricing/plan.rb', line 16 def to_json { name: @name, duration: @duration, cost: @cost } end |