Class: Array

Inherits:
Object show all
Defined in:
lib/h8/value.rb,
lib/h8/context.rb

Instance Method Summary collapse

Instance Method Details

#__js_select(callable) ⇒ Object

JS select() implementation



9
10
11
12
13
# File 'lib/h8/context.rb', line 9

def __js_select callable
  select { |item|
    callable.call item
  }
end

#indexOf(item) ⇒ Object

JS indexOf implementation



16
17
18
# File 'lib/h8/context.rb', line 16

def indexOf item
  index(item) || -1
end

#splice(start, len, *replace) ⇒ Object

JS splice() implementation



21
22
23
24
25
# File 'lib/h8/context.rb', line 21

def splice(start, len, *replace)
  ret = self[start, len]
  self[start, len] = replace
  ret
end

#to_ruby(depth = 0) ⇒ Object

Returns new array with all components converted to_ruby.

Returns:

  • new array with all components converted to_ruby



213
214
215
216
# File 'lib/h8/value.rb', line 213

def to_ruby depth=0
  depth += 1
  map { |x| x.to_ruby depth }
end