Class: Nodewrap::ByteDecoder::Expression

Inherits:
Object
  • Object
show all
Defined in:
lib/bytedecoder.rb

Defined Under Namespace

Classes: Array, Assignment, ConcatArray, ConcatStrings, Constant, ConstantAssignment, Defined, Hash, Infix, Literal, Prefix, Self, Send, Throw, ToRegexp, Variable

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(pc) ⇒ Expression

Returns a new instance of Expression.



53
54
55
# File 'lib/bytedecoder.rb', line 53

def initialize(pc)
  @pc = pc
end

Instance Attribute Details

#pcObject (readonly)

Returns the value of attribute pc.



51
52
53
# File 'lib/bytedecoder.rb', line 51

def pc
  @pc
end

Instance Method Details

#<=>(rhs) ⇒ Object



57
58
59
# File 'lib/bytedecoder.rb', line 57

def <=>(rhs)
  return @pc <=> rhs.pc
end

#fmt(arg) ⇒ Object



61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/bytedecoder.rb', line 61

def fmt(arg)
  if arg.respond_to?(:precedence)
    p = arg.precedence
  else
    p = 0
  end

  if p >= self.precedence then
    return "(#{arg})"
  else
    return arg
  end
end