Module: Basilik::Ref
- Included in:
- Load
- Defined in:
- lib/basilik/ref.rb
Instance Method Summary collapse
- #child(child_path) ⇒ Object
- #child?(child_path) ⇒ Boolean
- #children? ⇒ Boolean
- #name ⇒ Object
- #num_children ⇒ Object
- #parent ⇒ Object
- #root ⇒ Object
- #root? ⇒ Boolean
- #to_s ⇒ Object
- #val ⇒ Object
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
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
39 40 41 42 |
# File 'lib/basilik/ref.rb', line 39 def children? data = read data.is_a? Map and !data.empty? end |
#name ⇒ Object
5 6 7 |
# File 'lib/basilik/ref.rb', line 5 def name parse_path[-1] end |
#num_children ⇒ Object
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 |
#parent ⇒ Object
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 |
#root ⇒ Object
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
18 19 20 |
# File 'lib/basilik/ref.rb', line 18 def root? @uri.path.empty? or @uri.path == "/" end |
#to_s ⇒ Object
53 54 55 |
# File 'lib/basilik/ref.rb', line 53 def to_s @url end |
#val ⇒ Object
9 10 11 |
# File 'lib/basilik/ref.rb', line 9 def val read end |