Class: Stack::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/stack/configuration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hash = nil) ⇒ Configuration

Returns a new instance of Configuration.



6
7
8
# File 'lib/stack/configuration.rb', line 6

def initialize(hash = nil)
  self.from_hash(hash)
end

Instance Attribute Details

#server_portObject

Returns the value of attribute server_port.



4
5
6
# File 'lib/stack/configuration.rb', line 4

def server_port
  @server_port
end

#server_watchObject

Returns the value of attribute server_watch.



4
5
6
# File 'lib/stack/configuration.rb', line 4

def server_watch
  @server_watch
end

#sourceObject

Returns the value of attribute source.



3
4
5
# File 'lib/stack/configuration.rb', line 3

def source
  @source
end

#targetObject

Returns the value of attribute target.



3
4
5
# File 'lib/stack/configuration.rb', line 3

def target
  @target
end

Instance Method Details

#from_hash(hash) ⇒ Object



10
11
12
13
14
15
16
17
# File 'lib/stack/configuration.rb', line 10

def from_hash(hash)
  if (hash != nil)
    @source = hash[:source]
    @target = hash[:target]
    @server_port = hash[:server][:port]
    @server_watch = hash[:server][:watch]
  end
end

#to_hashObject



19
20
21
22
23
24
25
26
27
28
# File 'lib/stack/configuration.rb', line 19

def to_hash
  {
    :source => self.source,
    :target => self.target,
    :server => {
      :port => self.server_port,
      :watch => self.server_watch
    }
  }
end