Module: Basilik::Ref

Included in:
Load
Defined in:
lib/basilik/ref.rb

Instance Method Summary collapse

Instance Method Details

#child(child_path) ⇒ Object



28
29
30
# File 'lib/basilik/ref.rb', line 28

def child( child_path )
  Basilik::Load.new( "#{uri.to_s}/#{child_path}" )
end

#child?(child_path) ⇒ Boolean

Returns:

  • (Boolean)


32
33
34
35
36
37
# File 'lib/basilik/ref.rb', line 32

def child?( child_path )
  child( child_path ).read
  true
rescue
  false
end

#children?Boolean

Returns:

  • (Boolean)


39
40
41
42
# File 'lib/basilik/ref.rb', line 39

def children?
  data = read
  data.is_a? Map and !data.empty?
end

#nameObject



5
6
7
# File 'lib/basilik/ref.rb', line 5

def name
  parse_path[-1]
end

#num_childrenObject



44
45
46
47
48
49
50
51
# File 'lib/basilik/ref.rb', line 44

def num_children
  data = read
  if data.is_a? Map and !data.empty?
    data.count
  else
    0
  end
end

#parentObject



22
23
24
25
26
# File 'lib/basilik/ref.rb', line 22

def parent
  return nil if root?
  path = parse_path[0..-2].join( "/" )
  Basilik::Load.new( root.uri.merge(path).to_s )
end

#rootObject



13
14
15
16
# File 'lib/basilik/ref.rb', line 13

def root
  return self if root?
  Basilik::Load.new( @uri.scheme + '://' + @uri.host )            
end

#root?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/basilik/ref.rb', line 18

def root?
  @uri.path.empty? or @uri.path == "/"
end

#to_sObject



53
54
55
# File 'lib/basilik/ref.rb', line 53

def to_s
  @url
end

#valObject



9
10
11
# File 'lib/basilik/ref.rb', line 9

def val
  read
end