Module: SuperStack::LayerWrapper

Includes:
Comparable
Included in:
Layer
Defined in:
lib/super_stack/layer_wrapper.rb

Constant Summary collapse

DEFAULT_LAYER_NAME =
'Unknown layer'

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#file_nameObject (readonly)

Returns the value of attribute file_name.



10
11
12
# File 'lib/super_stack/layer_wrapper.rb', line 10

def file_name
  @file_name
end

#priorityObject

Returns the value of attribute priority.



10
11
12
# File 'lib/super_stack/layer_wrapper.rb', line 10

def priority
  @priority
end

Instance Method Details

#<=>(other) ⇒ Object



34
35
36
37
# File 'lib/super_stack/layer_wrapper.rb', line 34

def <=>(other)
  # For priorities, the smallest the higher
  self.priority <=> other.priority
end

#has_file?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/super_stack/layer_wrapper.rb', line 30

def has_file?
  !@file_name.nil?
end

#inspectObject



39
40
41
# File 'lib/super_stack/layer_wrapper.rb', line 39

def inspect
  "name: #{name}, priority: #{priority}, #{super}"
end

#load(file_name, type = :yaml) ⇒ Object



25
26
27
28
# File 'lib/super_stack/layer_wrapper.rb', line 25

def load(file_name, type = :yaml)
  raise 'Invalid file' unless File.readable? file_name
  load_from_yaml file_name if type == :yaml
end

#nameObject



21
22
23
# File 'lib/super_stack/layer_wrapper.rb', line 21

def name
  @name || DEFAULT_LAYER_NAME
end

#name=(name) ⇒ Object



17
18
19
# File 'lib/super_stack/layer_wrapper.rb', line 17

def name=(name)
  @name = name.to_s
end