class Ilp::Term

Attributes

mult[RW]
var[RW]

Public Class Methods

new(var, mult = 1) click to toggle source
# File lib/ruby-cbc/ilp/term.rb, line 5
def initialize(var, mult = 1)
  @mult = mult
  @var = var
end

Public Instance Methods

*(other) click to toggle source
# File lib/ruby-cbc/ilp/term.rb, line 30
def *(other)
  raise ArgumentError, "Argument is not numeric" unless other.is_a? Numeric
  Ilp::Term.new(@var, @mult * other)
end
+(other) click to toggle source
# File lib/ruby-cbc/ilp/term.rb, line 10
def +(other)
  Ilp::TermArray.new([self]) + other
end
-(other) click to toggle source
# File lib/ruby-cbc/ilp/term.rb, line 14
def -(other)
  Ilp::TermArray.new([self]) - other
end
<=(other) click to toggle source
# File lib/ruby-cbc/ilp/term.rb, line 22
def <=(other)
  Ilp::TermArray.new([self]) <= other
end
==(other) click to toggle source
# File lib/ruby-cbc/ilp/term.rb, line 18
def ==(other)
  Ilp::TermArray.new([self]) == other
end
>=(other) click to toggle source
# File lib/ruby-cbc/ilp/term.rb, line 26
def >=(other)
  Ilp::TermArray.new([self]) >= other
end
coerce(num) click to toggle source
# File lib/ruby-cbc/ilp/term.rb, line 35
def coerce(num)
  [Ilp::Constant.new(num), Ilp::TermArray.new([self])]
end
to_s() click to toggle source
# File lib/ruby-cbc/ilp/term.rb, line 39
def to_s
  str = "++-"[mult <=> 0] << " "
  str << mult.abs.to_s << " " if mult != 1
  str << var.to_s
end