Class: Sum

Inherits:
Latex show all
Defined in:
lib/annlat/LaRuby.rb

Instance Method Summary collapse

Methods inherited from Latex

#*, #**, #+, #-, #-@, #/, #glue, #is, #my_json, #ne, #of, #to_ltx, #wrap

Constructor Details

#initialize(*some_summands) ⇒ Sum

Returns a new instance of Sum.



153
154
155
# File 'lib/annlat/LaRuby.rb', line 153

def initialize(*some_summands)
  @summands = some_summands.map(&:to_ltx)
end

Instance Method Details

#latexObject



157
158
159
160
161
# File 'lib/annlat/LaRuby.rb', line 157

def latex 
  str = @summands[0].latex
  @summands[1..-1].each{|a| a.kind_of?(Negative) ? str += (a.latex) : str += ('+' + a.latex)}
  str
end