class Smartdown::Model::Answer::Base
Attributes
error[R]
question[R]
value[R]
Public Class Methods
new(value, question=nil)
click to toggle source
# File lib/smartdown/model/answer/base.rb, line 38 def initialize(value, question=nil) @question = question @value = check_value_not_nil(value) @value = parse_value(value) if valid? end
Public Instance Methods
*(other)
click to toggle source
# File lib/smartdown/model/answer/base.rb, line 24 def *(other) value * parse_other_object(other) end
+(other)
click to toggle source
# File lib/smartdown/model/answer/base.rb, line 20 def +(other) value + parse_other_object(other) end
-(other)
click to toggle source
# File lib/smartdown/model/answer/base.rb, line 16 def -(other) value - parse_other_object(other) end
/(other)
click to toggle source
# File lib/smartdown/model/answer/base.rb, line 28 def /(other) value / parse_other_object(other) end
<=>(other)
click to toggle source
# File lib/smartdown/model/answer/base.rb, line 32 def <=>(other) value <=> parse_other_object(other) end
invalid?()
click to toggle source
# File lib/smartdown/model/answer/base.rb, line 48 def invalid? !valid? end
valid?()
click to toggle source
# File lib/smartdown/model/answer/base.rb, line 44 def valid? @error.nil? end
value_type()
click to toggle source
# File lib/smartdown/model/answer/base.rb, line 12 def value_type ::String end
Private Instance Methods
check_value_not_nil(value)
click to toggle source
# File lib/smartdown/model/answer/base.rb, line 67 def check_value_not_nil(value) unless value @error = "Please answer this question" end value end
parse_other_object(comparison_object)
click to toggle source
# File lib/smartdown/model/answer/base.rb, line 53 def parse_other_object(comparison_object) if comparison_object.is_a? Base comparison_object.value elsif comparison_object.is_a? value_type comparison_object else parse_value(comparison_object) end end
parse_value(value)
click to toggle source
# File lib/smartdown/model/answer/base.rb, line 63 def parse_value(value) value end