Class: YNRequest
Instance Attribute Summary collapse
-
#hash ⇒ Object
readonly
Returns the value of attribute hash.
Instance Method Summary collapse
- #each ⇒ Object
- #get(key) ⇒ Object
-
#initialize(content = "") ⇒ YNRequest
constructor
A new instance of YNRequest.
Constructor Details
#initialize(content = "") ⇒ YNRequest
8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/yn_request.rb', line 8 def initialize(content="") @hash = Hash.new if content != "" _arr = [] _arr = content.include?("&") ? content.split("&") : _arr.push(content) _arr.each do |e| __arr = e.split("=") @hash[__arr[0].to_sym]=__arr[1] end end end |
Instance Attribute Details
#hash ⇒ Object (readonly)
Returns the value of attribute hash.
6 7 8 |
# File 'lib/yn_request.rb', line 6 def hash @hash end |
Instance Method Details
#each ⇒ Object
24 25 26 27 28 29 |
# File 'lib/yn_request.rb', line 24 def each raise 'please provide a block!' unless block_given? @hash.each do |e| yield e end end |
#get(key) ⇒ Object
20 21 22 |
# File 'lib/yn_request.rb', line 20 def get(key) @hash[key.to_sym] end |