Class: PfrpgCore::NullObject
- Inherits:
-
Numeric
- Object
- Numeric
- PfrpgCore::NullObject
show all
- Defined in:
- lib/pfrpg_core/null_object.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(*args, &block) ⇒ Object
17
18
19
|
# File 'lib/pfrpg_core/null_object.rb', line 17
def method_missing(*args, &block)
self
end
|
Class Method Details
.maybe(value) ⇒ Object
21
22
23
24
25
26
|
# File 'lib/pfrpg_core/null_object.rb', line 21
def self.maybe(value)
case value
when nil then NullObject.new
else value
end
end
|
Instance Method Details
#+(other) ⇒ Object
28
29
30
31
32
33
34
35
36
37
|
# File 'lib/pfrpg_core/null_object.rb', line 28
def +(other)
case other
when String
to_s + other
when Fixnum
to_i + other
when Float
to_f + other
end
end
|
#as_json(options = {}) ⇒ Object
13
14
15
|
# File 'lib/pfrpg_core/null_object.rb', line 13
def as_json(options={})
""
end
|
#empty? ⇒ Boolean
9
10
11
|
# File 'lib/pfrpg_core/null_object.rb', line 9
def empty?
true
end
|
#to_a ⇒ Object
3
|
# File 'lib/pfrpg_core/null_object.rb', line 3
def to_a; []; end
|
#to_f ⇒ Object
6
|
# File 'lib/pfrpg_core/null_object.rb', line 6
def to_f; 0.0; end
|
#to_i ⇒ Object
7
|
# File 'lib/pfrpg_core/null_object.rb', line 7
def to_i; 0; end
|
#to_s ⇒ Object
4
|
# File 'lib/pfrpg_core/null_object.rb', line 4
def to_s; ""; end
|
#to_str ⇒ Object
5
|
# File 'lib/pfrpg_core/null_object.rb', line 5
def to_str; ""; end
|