class SyntaxTree::YARV::NewRange

### Summary

‘newrange` creates a new range object from the top two values on the stack. It pops both of them off, and then pushes on the new range. It takes one argument which is 0 if the end is included or 1 if the end value is excluded.

### Usage

~~~ruby x = 0 y = 1 p (x..y), (x…y) ~~~

Attributes

exclude_end[R]

Public Class Methods

new(exclude_end) click to toggle source
# File lib/syntax_tree/yarv/instructions.rb, line 2475
def initialize(exclude_end)
  @exclude_end = exclude_end
end

Public Instance Methods

==(other) click to toggle source
# File lib/syntax_tree/yarv/instructions.rb, line 2491
def ==(other)
  other.is_a?(NewRange) && other.exclude_end == exclude_end
end
call(vm) click to toggle source
# File lib/syntax_tree/yarv/instructions.rb, line 2507
def call(vm)
  vm.push(Range.new(*vm.pop(2), exclude_end == 1))
end
deconstruct_keys(_keys) click to toggle source
# File lib/syntax_tree/yarv/instructions.rb, line 2487
def deconstruct_keys(_keys)
  { exclude_end: exclude_end }
end
disasm(fmt) click to toggle source
# File lib/syntax_tree/yarv/instructions.rb, line 2479
def disasm(fmt)
  fmt.instruction("newrange", [fmt.object(exclude_end)])
end
length() click to toggle source
# File lib/syntax_tree/yarv/instructions.rb, line 2495
def length
  2
end
pops() click to toggle source
# File lib/syntax_tree/yarv/instructions.rb, line 2499
def pops
  2
end
pushes() click to toggle source
# File lib/syntax_tree/yarv/instructions.rb, line 2503
def pushes
  1
end
to_a(_iseq) click to toggle source
# File lib/syntax_tree/yarv/instructions.rb, line 2483
def to_a(_iseq)
  [:newrange, exclude_end]
end