Class: HangoutsJsonParser::Attachment::Location

Inherits:
Attachment
  • Object
show all
Defined in:
lib/hangouts_json_parser/attachment/location.rb

Overview

A location attachment

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url) ⇒ Location

Returns a new instance of Location.



11
12
13
# File 'lib/hangouts_json_parser/attachment/location.rb', line 11

def initialize url
	@url = url
end

Instance Attribute Details

#urlString (readonly)

Returns url to the location on Google Maps.

Returns:

  • (String)

    url to the location on Google Maps



9
10
11
# File 'lib/hangouts_json_parser/attachment/location.rb', line 9

def url
  @url
end

Class Method Details

.from_message_attachment(data) ⇒ Location

Creates a Location from message data

Parameters:

  • data (Hash)

    attachment data

Returns:



18
19
20
21
22
# File 'lib/hangouts_json_parser/attachment/location.rb', line 18

def self.from_message_attachment data
	raise "Attachment passed is not a location" unless data.dig("embed_item", "type").eql? Location.type

	Location.new data.dig("embed_item", "id")
end

.typeArray

Returns type identifier of this attachment.

Returns:

  • (Array)

    type identifier of this attachment



25
26
27
# File 'lib/hangouts_json_parser/attachment/location.rb', line 25

def self.type
	["PLACE_V2", "THING_V2", "THING"]
end