Class: Smartdown::Model::Answer::Base
- Inherits:
-
Object
- Object
- Smartdown::Model::Answer::Base
show all
- Extended by:
- Forwardable
- Includes:
- Comparable
- Defined in:
- lib/smartdown/model/answer/base.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(value, question = nil) ⇒ Base
Returns a new instance of Base.
36
37
38
39
40
|
# File 'lib/smartdown/model/answer/base.rb', line 36
def initialize(value, question=nil)
@question = question
@value = check_value_not_nil(value)
@value = parse_value(value) if valid?
end
|
Instance Attribute Details
#error ⇒ Object
Returns the value of attribute error.
34
35
36
|
# File 'lib/smartdown/model/answer/base.rb', line 34
def error
@error
end
|
#question ⇒ Object
Returns the value of attribute question.
34
35
36
|
# File 'lib/smartdown/model/answer/base.rb', line 34
def question
@question
end
|
#value ⇒ Object
Returns the value of attribute value.
34
35
36
|
# File 'lib/smartdown/model/answer/base.rb', line 34
def value
@value
end
|
Instance Method Details
#*(other) ⇒ Object
22
23
24
|
# File 'lib/smartdown/model/answer/base.rb', line 22
def *(other)
value * parse_other_object(other)
end
|
#+(other) ⇒ Object
18
19
20
|
# File 'lib/smartdown/model/answer/base.rb', line 18
def +(other)
value + parse_other_object(other)
end
|
#-(other) ⇒ Object
14
15
16
|
# File 'lib/smartdown/model/answer/base.rb', line 14
def -(other)
value - parse_other_object(other)
end
|
#/(other) ⇒ Object
26
27
28
|
# File 'lib/smartdown/model/answer/base.rb', line 26
def /(other)
value / parse_other_object(other)
end
|
#<=>(other) ⇒ Object
30
31
32
|
# File 'lib/smartdown/model/answer/base.rb', line 30
def <=>(other)
value <=> parse_other_object(other)
end
|
#invalid? ⇒ Boolean
46
47
48
|
# File 'lib/smartdown/model/answer/base.rb', line 46
def invalid?
!valid?
end
|
#valid? ⇒ Boolean
42
43
44
|
# File 'lib/smartdown/model/answer/base.rb', line 42
def valid?
@error.nil?
end
|
#value_type ⇒ Object
10
11
12
|
# File 'lib/smartdown/model/answer/base.rb', line 10
def value_type
::String
end
|