Module Minpaso
In: lib/minpaso.rb

Methods

search  

Classes and Modules

Class Minpaso::PCInfo
Class Minpaso::SearchResultPager

Constants

VERSION = "002"

Public Class methods

params:See minpaso.goga.co.jp/ja-JP/api.php for details.
  • :manufacturer
  • :product_name
  • :cpu_name
  • :graphics_adapter
  • :wei_min
  • :wei_max
  • :cpu_min
  • :cpu_max
  • :memory_min
  • :memory_max
  • :game_min
  • :game_max
  • :hdd_min
  • :hdd_max
  • :total_min
  • :total_max
  • :s or :sort
  • :p or :page
  • :h
  • :e or :guess_score

[Source]

    # File lib/minpaso.rb, line 30
30:   def self.search(params={})
31:     uri = URI.parse("http://minpaso.goga.co.jp/api/search.php")
32:     params = params.inject(Hash.new) do |table, (k, v)|
33:       case k
34:       when :sort; table["s"] = v
35:       when :page; table["p"] = v
36:       when :guess_score; table["e"] = e
37:       else
38:         if k.to_s.size > 1
39:           table[k.to_s.capitalize.gsub(/_([a-z])/){$1.capitalize}] = v
40:         else
41:           table[k.to_s] = v
42:         end
43:       end
44:       table
45:     end
46:     keys = params.keys - ["Manufacturer", "ProductName", "CpuName", "GraphicsAdapter",
47:                           "WeiMin", "WeiMax", "CpuMin", "CpuMax", "MemoryMin",
48:                           "MemoryMax", "VideoMin", "VideoMax", "GameMin", "GameMax",
49:                           "HddMin", "HddMax", "TotalMin", "TotalMax", "s", "p",
50:                           "h", "e"]
51:     raise ArgumentError, keys if keys.size > 0
52:     uri.query = params.map{|k, v| k + "=" + v.to_s}.join("&")
53:     SearchResultPager.new(REXML::Document.new(uri.read), params)
54:   end

[Validate]