Class: ChatworkTo::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/chatwork_to/config.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts) ⇒ Config

Returns a new instance of Config.



5
6
7
8
9
10
11
# File 'lib/chatwork_to/config.rb', line 5

def initialize(opts)
  require_options!(opts)
  @chatwork_email = opts['chatwork']['email']
  @chatwork_pass  = opts['chatwork']['pass']
  @rooms          = Array[*opts['chatwork']['rooms']].map(&:to_s)
  @notifiers      = Array[*opts['notifiers']]
end

Instance Attribute Details

#chatwork_emailObject (readonly)

Returns the value of attribute chatwork_email.



3
4
5
# File 'lib/chatwork_to/config.rb', line 3

def chatwork_email
  @chatwork_email
end

#chatwork_passObject (readonly)

Returns the value of attribute chatwork_pass.



3
4
5
# File 'lib/chatwork_to/config.rb', line 3

def chatwork_pass
  @chatwork_pass
end

#notifiersObject (readonly)

Returns the value of attribute notifiers.



3
4
5
# File 'lib/chatwork_to/config.rb', line 3

def notifiers
  @notifiers
end

#roomsObject (readonly)

Returns the value of attribute rooms.



3
4
5
# File 'lib/chatwork_to/config.rb', line 3

def rooms
  @rooms
end

Class Method Details

.load(opts = {}) ⇒ Object



23
24
25
26
27
28
29
30
# File 'lib/chatwork_to/config.rb', line 23

def load(opts = {})
  conf_hash = load_yaml(opts)
  if conf_hash.present?
    new(conf_hash)
  else
    raise InvalidConfiguration, 'Nothing configuration'
  end
end