Class: Buby::BubyArrayWrapper

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/buby/extends/buby_array_wrapper.rb

Direct Known Subclasses

HttpRequestResponseList, ScanIssuesList

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (BubyArrayWrapper) initialize(obj)

A new instance of BubyArrayWrapper



8
9
10
# File 'lib/buby/extends/buby_array_wrapper.rb', line 8

def initialize(obj)
  @array_obj = obj
end

Instance Attribute Details

- (Object) array_obj (readonly)

Returns the value of attribute array_obj



6
7
8
# File 'lib/buby/extends/buby_array_wrapper.rb', line 6

def array_obj
  @array_obj
end

Instance Method Details

- (Object) [](*args)



12
13
14
15
16
17
18
# File 'lib/buby/extends/buby_array_wrapper.rb', line 12

def [](*args)
  if args.size == 1 and args.first.kind_of? Numeric
    self.array_obj[args[0]]
  else
    self.to_a(*args)
  end
end

- (Object) each



20
21
22
23
24
# File 'lib/buby/extends/buby_array_wrapper.rb', line 20

def each
  self.array_obj.size.times do |idx|
    yield self.array_obj[idx]
  end
end

- (Object) first



31
32
33
# File 'lib/buby/extends/buby_array_wrapper.rb', line 31

def first
  return(self.array_obj[0]) if(self.size > 0)
end

- (Object) last



35
36
37
# File 'lib/buby/extends/buby_array_wrapper.rb', line 35

def last
  return self.array_obj[self.size - 1] if(self.size > 0)
end

- (Object) size Also known as: length



26
27
28
# File 'lib/buby/extends/buby_array_wrapper.rb', line 26

def size
  self.array_obj.size
end