Class: Ec2Metadata::Revision

Inherits:
Base
  • Object
show all
Defined in:
lib/ec2_metadata/revision.rb

Instance Attribute Summary

Attributes inherited from Base

#default_child_key, #path

Instance Method Summary collapse

Methods inherited from Base

#child_keys, #children, #default_child, #from_hash, #get, #is_child_key?, #to_hash

Constructor Details

#initialize(path) ⇒ Revision

Returns a new instance of Revision.



5
6
7
8
# File 'lib/ec2_metadata/revision.rb', line 5

def initialize(path)
  @path = path
  @default_child_key = 'meta-data'
end

Instance Method Details

#is_struct?(child_key) ⇒ Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/ec2_metadata/revision.rb', line 18

def is_struct?(child_key)
  child_key =~ /^meta-data\/?$/
end

#new_child(child_key) ⇒ Object



10
11
12
13
14
15
16
# File 'lib/ec2_metadata/revision.rb', line 10

def new_child(child_key)
  logging("new_child(#{child_key.inspect})") do
    child_path = "#{path}#{child_key}"
    child_path << '/' if is_struct?(child_key)
    Base.new(child_path)
  end
end