Class: Iknow::Config

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/iknow/core/config.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#api_hostObject

Returns the value of attribute api_host.



5
6
7
# File 'lib/iknow/core/config.rb', line 5

def api_host
  @api_host
end

#api_keyObject

Returns the value of attribute api_key.



5
6
7
# File 'lib/iknow/core/config.rb', line 5

def api_key
  @api_key
end

#api_portObject

Returns the value of attribute api_port.



5
6
7
# File 'lib/iknow/core/config.rb', line 5

def api_port
  @api_port
end

#api_protocolObject

Returns the value of attribute api_protocol.



5
6
7
# File 'lib/iknow/core/config.rb', line 5

def api_protocol
  @api_protocol
end

#application_nameObject

Returns the value of attribute application_name.



5
6
7
# File 'lib/iknow/core/config.rb', line 5

def application_name
  @application_name
end

#application_urlObject

Returns the value of attribute application_url.



5
6
7
# File 'lib/iknow/core/config.rb', line 5

def application_url
  @application_url
end

#application_versionObject

Returns the value of attribute application_version.



5
6
7
# File 'lib/iknow/core/config.rb', line 5

def application_version
  @application_version
end

#hostObject

Returns the value of attribute host.



5
6
7
# File 'lib/iknow/core/config.rb', line 5

def host
  @host
end

#oauth_consumer_keyObject

Returns the value of attribute oauth_consumer_key.



5
6
7
# File 'lib/iknow/core/config.rb', line 5

def oauth_consumer_key
  @oauth_consumer_key
end

#oauth_consumer_secretObject

Returns the value of attribute oauth_consumer_secret.



5
6
7
# File 'lib/iknow/core/config.rb', line 5

def oauth_consumer_secret
  @oauth_consumer_secret
end

#portObject

Returns the value of attribute port.



5
6
7
# File 'lib/iknow/core/config.rb', line 5

def port
  @port
end

#protocolObject

Returns the value of attribute protocol.



5
6
7
# File 'lib/iknow/core/config.rb', line 5

def protocol
  @protocol
end

#sourceObject

Returns the value of attribute source.



5
6
7
# File 'lib/iknow/core/config.rb', line 5

def source
  @source
end

#timeoutObject

Returns the value of attribute timeout.



5
6
7
# File 'lib/iknow/core/config.rb', line 5

def timeout
  @timeout
end

#user_agentObject

Returns the value of attribute user_agent.



5
6
7
# File 'lib/iknow/core/config.rb', line 5

def user_agent
  @user_agent
end

Class Method Details

.init {|conf| ... } ⇒ Object

Yields:

  • (conf)


9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/iknow/core/config.rb', line 9

def self.init(&block)
  conf = Iknow::Config.instance
  { :protocol              => 'http',
    :host                  => 'www.iknow.co.jp',
    :port                  => 80,
    :api_protocol          => 'http',
    :api_host              => 'api.iknow.co.jp',
    :api_port              => 80,
    :timeout               => 5,
    :api_key               => '',
    :oauth_consumer_key    => '',
    :oauth_consumer_secret => '',
    :user_agent            => 'default',
    :application_name      => 'iKnow! Gem',
    :application_version   => Iknow::Version.to_version,
    :application_url       => 'http://github.com/nov/iknow'
  }.each do |key, value| conf.send("#{key}=", value) end
  yield conf if block_given?
  conf
end

.method_missing(method, *args) ⇒ Object



40
41
42
# File 'lib/iknow/core/config.rb', line 40

def self.method_missing(method, *args)
  self.instance.send(method, *args)
end

Instance Method Details

#iknow_api_base_urlObject



35
36
37
38
# File 'lib/iknow/core/config.rb', line 35

def iknow_api_base_url
  port = self.api_port==80 ? nil : ":#{self.api_port}"
  "#{self.api_protocol}://#{self.api_host}#{port}"
end

#iknow_base_urlObject



30
31
32
33
# File 'lib/iknow/core/config.rb', line 30

def iknow_base_url
  port = self.port==80 ? nil : ":#{self.port}"
  "#{self.protocol}://#{self.host}#{port}"
end