Class: Canals::Environment
- Inherits:
-
Object
- Object
- Canals::Environment
- Defined in:
- lib/canals/environment.rb
Instance Attribute Summary collapse
-
#hostname ⇒ Object
readonly
Returns the value of attribute hostname.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#pem ⇒ Object
readonly
Returns the value of attribute pem.
-
#user ⇒ Object
readonly
Returns the value of attribute user.
Instance Method Summary collapse
- #default=(val) ⇒ Object
-
#initialize(args) ⇒ Environment
constructor
A new instance of Environment.
- #is_default? ⇒ Boolean
- #to_hash ⇒ Object
- #to_yaml ⇒ Object
- #validate?(args) ⇒ Boolean
Constructor Details
#initialize(args) ⇒ Environment
Returns a new instance of Environment.
8 9 10 11 12 13 14 |
# File 'lib/canals/environment.rb', line 8 def initialize(args) @args = validate?(args) @name = @args[:name] @user = @args[:user] @hostname = @args[:hostname] @pem = @args[:pem] end |
Instance Attribute Details
#hostname ⇒ Object (readonly)
Returns the value of attribute hostname.
7 8 9 |
# File 'lib/canals/environment.rb', line 7 def hostname @hostname end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
7 8 9 |
# File 'lib/canals/environment.rb', line 7 def name @name end |
#pem ⇒ Object (readonly)
Returns the value of attribute pem.
7 8 9 |
# File 'lib/canals/environment.rb', line 7 def pem @pem end |
#user ⇒ Object (readonly)
Returns the value of attribute user.
7 8 9 |
# File 'lib/canals/environment.rb', line 7 def user @user end |
Instance Method Details
#default=(val) ⇒ Object
22 23 24 |
# File 'lib/canals/environment.rb', line 22 def default=(val) @args[:default] = !!val end |
#is_default? ⇒ Boolean
26 27 28 |
# File 'lib/canals/environment.rb', line 26 def is_default? !!@args[:default] end |
#to_hash ⇒ Object
34 35 36 |
# File 'lib/canals/environment.rb', line 34 def to_hash Marshal.load(Marshal.dump(@args)) end |
#to_yaml ⇒ Object
30 31 32 |
# File 'lib/canals/environment.rb', line 30 def to_yaml Canals::Tools::YAML.to_yaml(@args) end |
#validate?(args) ⇒ Boolean
16 17 18 19 20 |
# File 'lib/canals/environment.rb', line 16 def validate?(args) vargs = args.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo} raise CanalEnvironmentError.new("Missing option: \"name\" in environment creation") if vargs[:name].nil? vargs end |