Class: Machiawase::Rendezvous

Inherits:
Object
  • Object
show all
Defined in:
lib/machiawase/rendezvous.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*places) ⇒ Rendezvous

Returns a new instance of Rendezvous.

Parameters:

  • places (Array<Place>)

    the array of places.



16
17
18
19
# File 'lib/machiawase/rendezvous.rb', line 16

def initialize(*places)
  @place  = nil
  @places = places
end

Instance Attribute Details

#addressObject (readonly)

Returns the value of attribute address.



13
14
15
# File 'lib/machiawase/rendezvous.rb', line 13

def address
  @address
end

#latObject (readonly)

Returns the value of attribute lat.



13
14
15
# File 'lib/machiawase/rendezvous.rb', line 13

def lat
  @lat
end

#lonObject (readonly)

Returns the value of attribute lon.



13
14
15
# File 'lib/machiawase/rendezvous.rb', line 13

def lon
  @lon
end

#near_stationObject (readonly)

Returns the value of attribute near_station.



13
14
15
# File 'lib/machiawase/rendezvous.rb', line 13

def near_station
  @near_station
end

#placePlace (readonly)

Returns the place to rendezvous.

Returns:

  • (Place)

    the place to rendezvous.



13
14
15
# File 'lib/machiawase/rendezvous.rb', line 13

def place
  @place
end

#placesArray<Place> (readonly)

Returns the array of given places.

Returns:

  • (Array<Place>)

    the array of given places.

See Also:



13
# File 'lib/machiawase/rendezvous.rb', line 13

attr_reader :place, :places, :lat, :lon, :address, :near_station

Instance Method Details

#to_hHash

Returns the attributes with Hash format.

Returns:

  • (Hash)

    the attributes with Hash format.



46
47
48
49
50
51
52
53
54
# File 'lib/machiawase/rendezvous.rb', line 46

def to_h
  h = Hash.new
  @places.each_with_index do |place, i|
    h.store("place#{i}", place.to_h)        
  end

  @place ||= middle_of(*@places)
  h.store("machiawase", @place.to_h)
end

#to_jsonJSON

Returns the attributes with JSON format.

Returns:

  • (JSON)

    the attributes with JSON format.



57
58
59
# File 'lib/machiawase/rendezvous.rb', line 57

def to_json
  JSON.pretty_generate(to_h)
end

#to_msgpackObject



61
62
63
# File 'lib/machiawase/rendezvous.rb', line 61

def to_msgpack
  to_h.to_msgpack
end