Class: Rupture::Cons

Inherits:
Seq
  • Object
show all
Defined in:
lib/rupture/cons.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Seq

#==, #[], #each, empty, #to_ary

Methods included from Sequence

#concat, #conj, #count, #doall, #drop, #drop_last, #drop_while, #empty?, #every?, #filter, #flatten, #foldr, #inspect, #into, #last, #map, #mapcat, #next, #not_empty, #nth, #partition, #partition_all, #partition_between, #partition_by, #reduce, #remove, #reverse, #second, #separate, #sequential?, #some, #split_at, #split_with, #take, #take_last, #take_while, #tree_seq

Constructor Details

#initialize(first, rest) ⇒ Cons

Returns a new instance of Cons.



5
6
7
8
# File 'lib/rupture/cons.rb', line 5

def initialize(first, rest)
  @first, @rest = first, rest
  super()
end

Instance Attribute Details

#firstObject (readonly)

Returns the value of attribute first.



3
4
5
# File 'lib/rupture/cons.rb', line 3

def first
  @first
end

Instance Method Details

#restObject



14
15
16
# File 'lib/rupture/cons.rb', line 14

def rest
  @rest ||= Seq.empty
end

#seqObject



10
11
12
# File 'lib/rupture/cons.rb', line 10

def seq
  self
end