Class: RFunk::Tuple

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

Instance Method Summary collapse

Constructor Details

#initialize(values) ⇒ Tuple

Returns a new instance of Tuple.



3
4
5
6
# File 'lib/rfunk/tuple.rb', line 3

def initialize(values)
  @values = values
  deep_freeze
end

Instance Method Details

#value(*args) ⇒ Object



8
9
10
11
12
13
14
15
16
# File 'lib/rfunk/tuple.rb', line 8

def value(*args)
  index = args[0]

  if args.length == 1
    RFunk.option(values[index])
  else
    self.class.new(values.dup.tap { |v| v[index] = RFunk.option(args[1]) })
  end
end