Class: Resty::Options
- Inherits:
-
Object
- Object
- Resty::Options
- Defined in:
- lib/resty/options.rb
Constant Summary collapse
- CONFIG_FILE =
"#{Dir.home}/.ruby_resty.yml"
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Class Method Summary collapse
Instance Method Summary collapse
- #headers ⇒ Object
- #host ⇒ Object
- #host_alias ⇒ Object
-
#initialize(options) ⇒ Options
constructor
A new instance of Options.
- #password ⇒ Object
- #username ⇒ Object
- #verbose? ⇒ Boolean
Constructor Details
#initialize(options) ⇒ Options
Returns a new instance of Options.
9 10 11 12 13 14 15 16 17 |
# File 'lib/resty/options.rb', line 9 def initialize() @options = if [:headers] [:headers] = Options.parse_headers([:headers]) elsif host_alias load_config_file end end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
5 6 7 |
# File 'lib/resty/options.rb', line 5 def @options end |
Class Method Details
.build_pair(header) ⇒ Object
47 48 49 50 |
# File 'lib/resty/options.rb', line 47 def self.build_pair(header) pair = header.split(":") { pair.first.to_sym => pair.last } end |
.parse_headers(headers) ⇒ Object
43 44 45 |
# File 'lib/resty/options.rb', line 43 def self.parse_headers(headers) headers.inject({}) { |hash, header| hash.merge(build_pair(header)) } end |
Instance Method Details
#headers ⇒ Object
31 32 33 |
# File 'lib/resty/options.rb', line 31 def headers [:headers] || {} end |
#host ⇒ Object
19 20 21 |
# File 'lib/resty/options.rb', line 19 def host [:host] end |
#host_alias ⇒ Object
27 28 29 |
# File 'lib/resty/options.rb', line 27 def host_alias [:alias] end |
#password ⇒ Object
39 40 41 |
# File 'lib/resty/options.rb', line 39 def password [:password] end |
#username ⇒ Object
35 36 37 |
# File 'lib/resty/options.rb', line 35 def username [:username] end |
#verbose? ⇒ Boolean
23 24 25 |
# File 'lib/resty/options.rb', line 23 def verbose? [:verbose] ? true : false end |