class Calcula::Exprs::BracedExpr
Expression for bracket operators. Floor operators also count as bracket operators.
@author Paul T.
Public Class Methods
new(startTok, endTok, inner)
click to toggle source
@param startTok [Calcula::Token] The starting token of this expression @param endTok [Calcula::Token] The ending token of this expression @param inner [Calcula::Expr]
# File lib/Exprs/BracedExpr.rb, line 12 def initialize(startTok, endTok, inner) @startTok = startTok @endTok = endTok @inner = inner end
Public Instance Methods
children()
click to toggle source
@see Calcula::Expr#children
@param (see Calcula::Expr#children
) @return (see Calcula::Expr#children
)
# File lib/Exprs/BracedExpr.rb, line 45 def children [@inner] end
to_s(form: :src)
click to toggle source
@see Calcula::Expr#to_s
@param (see Calcula::Expr#to_s
) @return (see Calcula::Expr#to_s
)
# File lib/Exprs/BracedExpr.rb, line 21 def to_s(form: :src) innerTxt = @inner.to_s(form: form) case form when :src then "#{@startTok.text}#{innerTxt}#{@endTok.text}" when :tree then "#{@startTok.text} #{innerTxt} #{@endTok.text}" when :ruby then case @startTok.id when :PAREN_O then "(#{innerTxt})" when :SQUARE_O then "(#{innerTxt}).floor.to_r" else raise "Unknown delimiter #{@startTok.id}" end else nil end end