Module: ROC::Types::ArrayType

Included in:
List, Set, SortedSet
Defined in:
lib/roc/types/array_type.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



7
8
9
# File 'lib/roc/types/array_type.rb', line 7

def self.included(base)
  base.send :delegate_methods, :on => [], :to => :values
end

Instance Method Details

#<<(val) ⇒ Object

Raises:

  • (NotImplementedError)


72
73
74
# File 'lib/roc/types/array_type.rb', line 72

def <<(val)
  raise NotImplementedError
end

#clearObject



54
55
56
# File 'lib/roc/types/array_type.rb', line 54

def clear
  self.replace([])
end

#clobber(data) ⇒ Object

Raises:

  • (NotImplementedError)


17
18
19
# File 'lib/roc/types/array_type.rb', line 17

def clobber(data)
  raise NotImplementedError, 'clobber must be overriden in any class including ArrayType'
end

#delete(val) ⇒ Object

destructive methods that would otherwise be delegated – override if possible (these are in addition to a ny methods ending in ! or =, which are caught by method_missing)

Raises:

  • (NotImplementedError)


60
61
62
# File 'lib/roc/types/array_type.rb', line 60

def delete(val)
  raise NotImplementedError
end

#delete_at(ind) ⇒ Object

Raises:

  • (NotImplementedError)


64
65
66
# File 'lib/roc/types/array_type.rb', line 64

def delete_at(ind)
  raise NotImplementedError
end

#delete_ifObject

Raises:

  • (NotImplementedError)


68
69
70
# File 'lib/roc/types/array_type.rb', line 68

def delete_if
  raise NotImplementedError
end

#fill(*args) ⇒ Object

Raises:

  • (NotImplementedError)


76
77
78
# File 'lib/roc/types/array_type.rb', line 76

def fill(*args)
  raise NotImplementedError
end

#insert(*args) ⇒ Object

Raises:

  • (NotImplementedError)


80
81
82
# File 'lib/roc/types/array_type.rb', line 80

def insert(*args)
  raise NotImplementedError
end

#inspectObject



43
44
45
# File 'lib/roc/types/array_type.rb', line 43

def inspect
  "<#{self.class} @storage=#{self.storage.inspect} @key=#{self.key.inspect} @size=#{self.size}>"
end

#keep_ifObject

Raises:

  • (NotImplementedError)


84
85
86
# File 'lib/roc/types/array_type.rb', line 84

def keep_if
  raise NotImplementedError
end

#pop(*args) ⇒ Object

Raises:

  • (NotImplementedError)


92
93
94
# File 'lib/roc/types/array_type.rb', line 92

def pop(*args)
  raise NotImplementedError
end

#push(*args) ⇒ Object

Raises:

  • (NotImplementedError)


88
89
90
# File 'lib/roc/types/array_type.rb', line 88

def push(*args)
  raise NotImplementedError
end

#replace(val) ⇒ Object

destructive methods that we can implement here



49
50
51
52
# File 'lib/roc/types/array_type.rb', line 49

def replace(val)
  self.clobber(val)
  self
end

#shift(*args) ⇒ Object

Raises:

  • (NotImplementedError)


96
97
98
# File 'lib/roc/types/array_type.rb', line 96

def shift(*args)
  raise NotImplementedError
end

#sizeObject

methods that must be implemented

Raises:

  • (NotImplementedError)


13
14
15
# File 'lib/roc/types/array_type.rb', line 13

def size
  raise NotImplementedError, 'size must be overriden in any class including ArrayType'
end

#to_aObject



35
36
37
# File 'lib/roc/types/array_type.rb', line 35

def to_a
  self.values
end

#to_arrayObject

can’t alias - it will to find the method in subclass



29
30
31
# File 'lib/roc/types/array_type.rb', line 29

def to_array 
  self.values
end

#to_aryObject



32
33
34
# File 'lib/roc/types/array_type.rb', line 32

def to_ary
  self.values
end

#unshift(*args) ⇒ Object

Raises:

  • (NotImplementedError)


100
101
102
# File 'lib/roc/types/array_type.rb', line 100

def unshift(*args)
  raise NotImplementedError
end

#valuesObject

note - overriden methods should always return an array, never nil

Raises:

  • (NotImplementedError)


22
23
24
# File 'lib/roc/types/array_type.rb', line 22

def values
  raise NotImplementedError, 'values must be overriden in any class including ArrayType'
end

#values=(data) ⇒ Object



39
40
41
# File 'lib/roc/types/array_type.rb', line 39

def values=(data)
  self.clobber(data)
end