Module: Machiawase

Defined in:
lib/machiawase.rb,
lib/machiawase/place.rb,
lib/machiawase/version.rb,
lib/machiawase/rendezvous.rb

Overview

Author:

Defined Under Namespace

Classes: Place, Rendezvous

Constant Summary collapse

VERSION =
"0.7.0"

Class Method Summary collapse

Class Method Details

.parse_proxy(proxy) ⇒ Object


29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/machiawase.rb', line 29

def self.parse_proxy(proxy)
  # http://user:[email protected]:port のように書かれていることを想定
  # パスワードに@とか入ってる場合があるので一番後ろの@でだけsplitする
  rserver, raccount = (proxy || '').sub(/http:\/\//, '').reverse.split("@", 2)
  server  = rserver.nil? ? "" : rserver.reverse
  host, port = server.split(":")
   = raccount.nil? ? "" : raccount.reverse.split(":")
  user, pass = 
  
  proxy = OpenStruct.new({      
                           "server" => server.empty? ? nil : "http://#{server}",
                           "user"   => user.nil? ? "" : user,
                           "pass"   => pass.nil? ? "" : pass
                         })
end

.where(*addresses) ⇒ Place

Returns the place to rendezvous.

Parameters:

  • argv (Array<Place>)

    the array of places.

Returns:

  • (Place)

    the place to rendezvous.


19
20
21
22
23
24
25
26
27
# File 'lib/machiawase.rb', line 19

def self.where(*addresses)
  places = Array.new
  addresses.each do |address|
    g = Place.geocode(address)
    places << Place.new(g['lat'], g['lon'])
  end
  m = Rendezvous.new(*places)
  m.place
end