Class: DocumentHash::Nil

Inherits:
Object
  • Object
show all
Defined in:
lib/document_hash/core.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(parent = nil, hash_path = nil) ⇒ Nil

Returns a new instance of Nil.



9
10
11
12
# File 'lib/document_hash/core.rb', line 9

def initialize parent = nil, hash_path = nil
  @parent = parent
  @path = hash_path 
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args) ⇒ Object



22
23
24
25
26
27
28
# File 'lib/document_hash/core.rb', line 22

def method_missing method, *args
  if method =~ /^(.*)=/
    parent.__send__ :create_path, (self.path << $1.to_sym), args.pop
  else
    return self.class.new( self.parent, self.path << method)
  end
end

Instance Attribute Details

#parentObject

Returns the value of attribute parent.



4
5
6
# File 'lib/document_hash/core.rb', line 4

def parent
  @parent
end

Instance Method Details

#==(val) ⇒ Object



18
19
20
# File 'lib/document_hash/core.rb', line 18

def == val
  val == false 
end

#nil?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/document_hash/core.rb', line 14

def nil?
  true
end

#pathObject



5
6
7
# File 'lib/document_hash/core.rb', line 5

def path
  @path ||= []
end