Class: YNRequest

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/yn_request.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#hashObject (readonly)

Returns the value of attribute hash.



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

def hash
  @hash
end

Instance Method Details

#eachObject



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