Class: Object
Overview
Define some built-in Inform helper methods
Instance Method Summary
collapse
Methods included from Logging
#log, log_level, log_level=
#ephemeral?, #object?
#matches?, #matches_any_exactly?, #matches_exactly?, #matches_last_exactly?
#in?, #notin?
Instance Method Details
31
32
33
|
# File 'lib/story_teller/mixins.rb', line 31
def +(other)
format(JoinedTemplate, str: self.to_s, other: other.to_s)
end
|
#blank? ⇒ Boolean
60
61
62
|
# File 'lib/story_teller/mixins.rb', line 60
def blank?
respond_to?(:empty?) ? empty? : self.nil?
end
|
35
36
37
38
39
40
41
42
|
# File 'lib/story_teller/mixins.rb', line 35
def identity
identification = { klass: self.class }
identifier = (self.respond_to?(:object?) && self.object? ? self.id : self.object_id) || 0
identification[:name] = (self.respond_to?(:name) ? self.name : nil) || 'unnamed'
identification[:hex] = identifier << 1
identification[:id] = identifier
format(ObjectIdentityTemplate, identification)
end
|
#negative? ⇒ Boolean
54
55
56
57
58
|
# File 'lib/story_teller/mixins.rb', line 54
def negative?
self.to_s.match?(/\A-?\d+?(\.\d+)?\Z/)
end
|
#number? ⇒ Boolean
44
45
46
|
# File 'lib/story_teller/mixins.rb', line 44
def number?
self.to_s.match?(/\A[+-]?\d+?(\.\d+)?\Z/)
end
|
#positive? ⇒ Boolean
48
49
50
51
52
|
# File 'lib/story_teller/mixins.rb', line 48
def positive?
self.to_s.match?(/\A+?\d+?(\.\d+)?\Z/)
end
|