Class: Rust::FactorValue
Overview
Represents a single value in a factor.
Instance Method Summary
collapse
Constructor Details
#initialize(value, level) ⇒ FactorValue
Creates a factor with a given value
(numeric) and level
(symbolic).
107
108
109
110
|
# File 'lib/rust/core/types/factor.rb', line 107
def initialize(value, level)
@value = value
@level = level
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
154
155
156
|
# File 'lib/rust/core/types/factor.rb', line 154
def method_missing(method, *args, &block)
@level.method(method).call(*args, &block)
end
|
Instance Method Details
#==(other) ⇒ Object
136
137
138
139
140
141
142
143
144
|
# File 'lib/rust/core/types/factor.rb', line 136
def ==(other)
if other.is_a?(FactorValue)
@value == other.value && @level == other.level
elsif other.is_a?(Integer)
@value == other
elsif other.is_a?(Symbol)
@level == other
end
end
|
#eql?(other) ⇒ Boolean
150
151
152
|
# File 'lib/rust/core/types/factor.rb', line 150
def eql?(other)
return self == other
end
|
146
147
148
|
# File 'lib/rust/core/types/factor.rb', line 146
def hash
@value.hash + @level.hash
end
|
132
133
134
|
# File 'lib/rust/core/types/factor.rb', line 132
def inspect
@level.inspect
end
|
116
117
118
|
# File 'lib/rust/core/types/factor.rb', line 116
def level
@level
end
|
120
121
122
|
# File 'lib/rust/core/types/factor.rb', line 120
def to_i
@value
end
|
128
129
130
|
# File 'lib/rust/core/types/factor.rb', line 128
def to_R
self.to_i
end
|
124
125
126
|
# File 'lib/rust/core/types/factor.rb', line 124
def to_sym
@level
end
|
112
113
114
|
# File 'lib/rust/core/types/factor.rb', line 112
def value
@value
end
|