Class: Object

Inherits:
BasicObject
Includes:
Inform::Matchers, Inform::ObjectHelpers, Inform::SetHelpers, Logging
Defined in:
lib/runtime/mixins.rb,
lib/runtime/helpers.rb,
lib/runtime/helpers.rb,
lib/runtime/logging.rb

Overview

The Object class

Constant Summary

Constants included from Logging

Logging::ForwardSlashPattern

Instance Method Summary collapse

Methods included from Logging

config, #get_formatted_logger_name, #init_java_logger, #init_logger, #init_ruby_logger, #log, log_level, log_level=, #ruby_log_formatter, #symbolize_numeric_log_level

Methods included from Inform::ObjectHelpers

#object?, #sysobj?

Methods included from Inform::Matchers

#matches?, #matches_any_exactly?, #matches_exactly?, #matches_last_exactly?

Methods included from Inform::SetHelpers

#in?, #notin?

Instance Method Details

#+(other) ⇒ Object



30
31
32
# File 'lib/runtime/mixins.rb', line 30

def +(other)
  format(JoinedTemplate, str: self.to_s, other: other.to_s)
end

#blank?Boolean



59
60
61
# File 'lib/runtime/mixins.rb', line 59

def blank?
  respond_to?(:empty?) ? empty? : self.nil?
end

#identityObject



34
35
36
37
38
39
40
41
# File 'lib/runtime/mixins.rb', line 34

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



53
54
55
56
57
# File 'lib/runtime/mixins.rb', line 53

def negative?
  # TODO: This might be as simple as:
  # self.to_i.negative?
  self.to_s.match?(/\A-?\d+?(\.\d+)?\Z/)
end

#number?Boolean



43
44
45
# File 'lib/runtime/mixins.rb', line 43

def number?
  self.to_s.match?(/\A[+-]?\d+?(\.\d+)?\Z/)
end

#positive?Boolean



47
48
49
50
51
# File 'lib/runtime/mixins.rb', line 47

def positive?
  # TODO: This might be as simple as:
  # self.to_i.positive?
  self.to_s.match?(/\A+?\d+?(\.\d+)?\Z/)
end