class Subclub::Client

Attributes

card_id[RW]
pin_id[RW]

Public Class Methods

new() click to toggle source
# File lib/subclub_wrapper.rb, line 11
def initialize

end

Public Instance Methods

history() click to toggle source
# File lib/subclub_wrapper.rb, line 48
def history
  doc = Nokogiri::HTML(login)
  hist = Array.new()
  ths = doc.xpath('//table[@class="list2"]/tr/th')
  doc.xpath('//table[@class="list2"]/tr').drop(1).each do |trs|
    temp = Hash.new()
    i = 0
    ths.each do |th|
      temp.store(th.text,trs.xpath('td')[i].text)
      i += 1
    end
    hist.push(temp)
  end
  hist
end
info() click to toggle source
# File lib/subclub_wrapper.rb, line 39
def info
  doc = Nokogiri::HTML(login)
  infos = Hash.new()
  doc.xpath('//table[@class="list1"]/tr[@class="odd"]').each do |trs|
    infos.store(trs.xpath('th').text,trs.xpath('td').text)
  end
  infos
end
login() click to toggle source
# File lib/subclub_wrapper.rb, line 15
def login
  response = nil
  tmpdoc = nil
  uri = URI.parse("https://rapico.jp/R03F764SUBWAY/PcCard/login?")
  http = Net::HTTP.new(uri.host, uri.port)
  http.use_ssl = true
  http.verify_mode = OpenSSL::SSL::VERIFY_NONE
  #http.set_debug_output $stderr
  http.start do |h|
    request = Net::HTTP::Post.new(uri.path)
    request['user-agent'] = "Ruby/#{RUBY_VERSION} MyHttpClient"
    request.set_form_data({
      :card_id      => @card_id,
      :pin_id       => @pin_id,
      :save_card_id => 0,
      :flg_post     => 1}, "&")
    response = h.request(request)
    cookie = response.get_fields('Set-Cookie')
    tmpdoc = h.get(response['location'],
                {'Cookie' => cookie[1]}).body
  end
  tmpdoc
end