twitter 8.2.0 → 8.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (100) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE.md +1 -1
  3. data/README.md +172 -10
  4. data/lib/twitter/arguments.rb +14 -1
  5. data/lib/twitter/base.rb +72 -11
  6. data/lib/twitter/basic_user.rb +7 -1
  7. data/lib/twitter/client.rb +94 -3
  8. data/lib/twitter/creatable.rb +11 -2
  9. data/lib/twitter/cursor.rb +58 -11
  10. data/lib/twitter/direct_message.rb +32 -4
  11. data/lib/twitter/direct_message_event.rb +34 -10
  12. data/lib/twitter/direct_messages/welcome_message.rb +22 -1
  13. data/lib/twitter/direct_messages/welcome_message_rule.rb +7 -0
  14. data/lib/twitter/direct_messages/welcome_message_rule_wrapper.rb +26 -3
  15. data/lib/twitter/direct_messages/welcome_message_wrapper.rb +36 -11
  16. data/lib/twitter/entities.rb +84 -8
  17. data/lib/twitter/entity/hashtag.rb +7 -1
  18. data/lib/twitter/entity/symbol.rb +7 -1
  19. data/lib/twitter/entity/uri.rb +2 -1
  20. data/lib/twitter/entity/user_mention.rb +20 -1
  21. data/lib/twitter/entity.rb +7 -1
  22. data/lib/twitter/enumerable.rb +20 -3
  23. data/lib/twitter/error.rb +137 -61
  24. data/lib/twitter/factory.rb +9 -5
  25. data/lib/twitter/geo/point.rb +37 -5
  26. data/lib/twitter/geo/polygon.rb +1 -0
  27. data/lib/twitter/geo.rb +16 -2
  28. data/lib/twitter/geo_factory.rb +7 -3
  29. data/lib/twitter/geo_results.rb +39 -8
  30. data/lib/twitter/headers.rb +44 -7
  31. data/lib/twitter/identity.rb +13 -3
  32. data/lib/twitter/language.rb +21 -1
  33. data/lib/twitter/list.rb +101 -11
  34. data/lib/twitter/media/animated_gif.rb +1 -0
  35. data/lib/twitter/media/photo.rb +19 -3
  36. data/lib/twitter/media/video.rb +21 -3
  37. data/lib/twitter/media/video_info.rb +15 -1
  38. data/lib/twitter/media_factory.rb +7 -3
  39. data/lib/twitter/metadata.rb +14 -1
  40. data/lib/twitter/null_object.rb +16 -14
  41. data/lib/twitter/oembed.rb +56 -2
  42. data/lib/twitter/place.rb +74 -6
  43. data/lib/twitter/premium_search_results.rb +87 -18
  44. data/lib/twitter/profile.rb +100 -44
  45. data/lib/twitter/profile_banner.rb +9 -4
  46. data/lib/twitter/rate_limit.rb +32 -3
  47. data/lib/twitter/relationship.rb +8 -5
  48. data/lib/twitter/rest/account_activity.rb +55 -26
  49. data/lib/twitter/rest/api.rb +2 -0
  50. data/lib/twitter/rest/client.rb +18 -0
  51. data/lib/twitter/rest/direct_messages/welcome_messages.rb +89 -18
  52. data/lib/twitter/rest/direct_messages.rb +158 -94
  53. data/lib/twitter/rest/favorites.rb +57 -21
  54. data/lib/twitter/rest/form_encoder.rb +57 -17
  55. data/lib/twitter/rest/friends_and_followers.rb +101 -35
  56. data/lib/twitter/rest/help.rb +13 -3
  57. data/lib/twitter/rest/lists.rb +133 -45
  58. data/lib/twitter/rest/oauth.rb +23 -17
  59. data/lib/twitter/rest/places_and_geo.rb +44 -28
  60. data/lib/twitter/rest/premium_search.rb +18 -13
  61. data/lib/twitter/rest/request.rb +171 -53
  62. data/lib/twitter/rest/saved_searches.rb +22 -7
  63. data/lib/twitter/rest/search.rb +20 -16
  64. data/lib/twitter/rest/spam_reporting.rb +5 -1
  65. data/lib/twitter/rest/suggested_users.rb +14 -5
  66. data/lib/twitter/rest/timelines.rb +92 -52
  67. data/lib/twitter/rest/trends.rb +31 -12
  68. data/lib/twitter/rest/tweets.rb +145 -88
  69. data/lib/twitter/rest/undocumented.rb +11 -2
  70. data/lib/twitter/rest/upload_utils.rb +42 -26
  71. data/lib/twitter/rest/users.rb +150 -71
  72. data/lib/twitter/rest/utils.rb +135 -39
  73. data/lib/twitter/saved_search.rb +23 -2
  74. data/lib/twitter/search_results.rb +62 -17
  75. data/lib/twitter/settings.rb +37 -11
  76. data/lib/twitter/size.rb +37 -3
  77. data/lib/twitter/source_user.rb +4 -3
  78. data/lib/twitter/streaming/client.rb +60 -8
  79. data/lib/twitter/streaming/connection.rb +55 -8
  80. data/lib/twitter/streaming/deleted_tweet.rb +8 -0
  81. data/lib/twitter/streaming/event.rb +43 -1
  82. data/lib/twitter/streaming/friend_list.rb +1 -0
  83. data/lib/twitter/streaming/message_parser.rb +20 -10
  84. data/lib/twitter/streaming/response.rb +31 -5
  85. data/lib/twitter/streaming/stall_warning.rb +23 -0
  86. data/lib/twitter/suggestion.rb +25 -1
  87. data/lib/twitter/target_user.rb +2 -1
  88. data/lib/twitter/trend.rb +29 -1
  89. data/lib/twitter/trend_results.rb +50 -7
  90. data/lib/twitter/tweet.rb +180 -21
  91. data/lib/twitter/user.rb +289 -53
  92. data/lib/twitter/utils.rb +12 -13
  93. data/lib/twitter/variant.rb +12 -1
  94. data/lib/twitter/version.rb +66 -29
  95. data/lib/twitter.rb +6 -1
  96. metadata +23 -57
  97. data/.yardopts +0 -16
  98. data/CHANGELOG.md +0 -1040
  99. data/CONTRIBUTING.md +0 -49
  100. data/twitter.gemspec +0 -40
@@ -2,15 +2,25 @@ require "equalizer"
2
2
  require "twitter/base"
3
3
 
4
4
  module Twitter
5
- class Identity < Twitter::Base
5
+ # Base class for Twitter objects with an identity
6
+ class Identity < Base
6
7
  include Equalizer.new(:id)
8
+
9
+ # The unique identifier for this object
10
+ #
11
+ # @api public
12
+ # @example
13
+ # tweet.id
7
14
  # @return [Integer]
8
15
  attr_reader :id
9
16
 
10
17
  # Initializes a new object
11
18
  #
12
- # @param attrs [Hash]
13
- # @raise [ArgumentError] Error raised when supplied argument is missing an :id key.
19
+ # @api public
20
+ # @example
21
+ # Twitter::Identity.new(id: 123)
22
+ # @param attrs [Hash] The attributes hash
23
+ # @raise [ArgumentError] Error raised when argument is missing an :id key
14
24
  # @return [Twitter::Identity]
15
25
  def initialize(attrs = {})
16
26
  attrs.fetch(:id)
@@ -1,7 +1,27 @@
1
1
  require "twitter/base"
2
2
 
3
3
  module Twitter
4
- class Language < Twitter::Base
4
+ # Represents a Twitter supported language
5
+ class Language < Base
6
+ # The language code
7
+ #
8
+ # @api public
9
+ # @example
10
+ # language.code
11
+ # @return [String]
12
+
13
+ # The language name
14
+ #
15
+ # @api public
16
+ # @example
17
+ # language.name
18
+ # @return [String]
19
+
20
+ # The language status
21
+ #
22
+ # @api public
23
+ # @example
24
+ # language.status
5
25
  # @return [String]
6
26
  attr_reader :code, :name, :status
7
27
  end
data/lib/twitter/list.rb CHANGED
@@ -2,37 +2,127 @@ require "twitter/creatable"
2
2
  require "twitter/identity"
3
3
 
4
4
  module Twitter
5
- class List < Twitter::Identity
6
- include Twitter::Creatable
5
+ # Represents a Twitter list
6
+ class List < Identity
7
+ include Creatable
8
+
9
+ # The number of members in this list
10
+ #
11
+ # @api public
12
+ # @example
13
+ # list.member_count
14
+ # @return [Integer]
15
+
16
+ # The number of subscribers to this list
17
+ #
18
+ # @api public
19
+ # @example
20
+ # list.subscriber_count
7
21
  # @return [Integer]
8
22
  attr_reader :member_count, :subscriber_count
23
+
24
+ # The description of this list
25
+ #
26
+ # @api public
27
+ # @example
28
+ # list.description
29
+ # @return [String]
30
+
31
+ # The full name of this list
32
+ #
33
+ # @api public
34
+ # @example
35
+ # list.full_name
36
+ # @return [String]
37
+
38
+ # The mode of this list (public or private)
39
+ #
40
+ # @api public
41
+ # @example
42
+ # list.mode
43
+ # @return [String]
44
+
45
+ # The name of this list
46
+ #
47
+ # @api public
48
+ # @example
49
+ # list.name
50
+ # @return [String]
51
+
52
+ # The slug of this list
53
+ #
54
+ # @api public
55
+ # @example
56
+ # list.slug
9
57
  # @return [String]
10
58
  attr_reader :description, :full_name, :mode, :name, :slug
11
59
 
12
60
  object_attr_reader :User, :user
13
61
  predicate_attr_reader :following
14
62
 
15
- # @return [Addressable::URI] The URI to the list members.
63
+ # Returns the URI to the list members
64
+ #
65
+ # @api public
66
+ # @example
67
+ # list.members_uri
68
+ # @return [URI::Generic]
16
69
  def members_uri
17
- Addressable::URI.parse("#{uri}/members") if uri?
70
+ URI.parse("#{uri}/members") if uri?
18
71
  end
19
72
  memoize :members_uri
20
- alias members_url members_uri
21
73
 
22
- # @return [Addressable::URI] The URI to the list subscribers.
74
+ # @!method members_url
75
+ # Returns the URL to the list members
76
+ # @api public
77
+ # @example
78
+ # list.members_url
79
+ # @return [URI::Generic]
80
+ alias_method :members_url, :members_uri
81
+
82
+ # Returns the URI to the list subscribers
83
+ #
84
+ # @api public
85
+ # @example
86
+ # list.subscribers_uri
87
+ # @return [URI::Generic]
23
88
  def subscribers_uri
24
- Addressable::URI.parse("#{uri}/subscribers") if uri?
89
+ URI.parse("#{uri}/subscribers") if uri?
25
90
  end
26
91
  memoize :subscribers_uri
27
- alias subscribers_url subscribers_uri
28
92
 
29
- # @return [Addressable::URI] The URI to the list.
93
+ # @!method subscribers_url
94
+ # Returns the URL to the list subscribers
95
+ # @api public
96
+ # @example
97
+ # list.subscribers_url
98
+ # @return [URI::Generic]
99
+ alias_method :subscribers_url, :subscribers_uri
100
+
101
+ # Returns the URI to the list
102
+ #
103
+ # @api public
104
+ # @example
105
+ # list.uri
106
+ # @return [URI::Generic]
30
107
  def uri
31
- Addressable::URI.parse("https://twitter.com/#{user.screen_name}/#{slug}") if slug? && user.screen_name?
108
+ URI.parse("https://twitter.com/#{user.screen_name}/#{slug}") if slug? && user.screen_name?
32
109
  end
33
110
  memoize :uri
34
- alias url uri
35
111
 
112
+ # @!method url
113
+ # Returns the URL to the list
114
+ # @api public
115
+ # @example
116
+ # list.url
117
+ # @return [URI::Generic]
118
+ alias_method :url, :uri
119
+
120
+ # Returns true if a URI is available for this list
121
+ #
122
+ # @api public
123
+ # @example
124
+ # list.uri?
125
+ # @return [Boolean]
36
126
  def uri?
37
127
  !!uri
38
128
  end
@@ -2,6 +2,7 @@ require "twitter/media/video"
2
2
 
3
3
  module Twitter
4
4
  module Media
5
+ # Represents a Twitter animated GIF media object
5
6
  class AnimatedGif < Video
6
7
  end
7
8
  end
@@ -2,24 +2,40 @@ require "memoizable"
2
2
  require "twitter/identity"
3
3
 
4
4
  module Twitter
5
+ # Namespace for Twitter media types
5
6
  module Media
7
+ # Represents a Twitter photo media object
6
8
  class Photo < Twitter::Identity
7
9
  include Memoizable
8
10
 
11
+ # The indices of this media in the text
12
+ #
13
+ # @api public
14
+ # @example
15
+ # photo.indices
9
16
  # @return [Array<Integer>]
10
17
  attr_reader :indices
11
18
 
19
+ # The media type
20
+ #
21
+ # @api public
22
+ # @example
23
+ # photo.type
12
24
  # @return [String]
13
25
  attr_reader :type
14
26
 
15
27
  display_uri_attr_reader
16
28
  uri_attr_reader :expanded_uri, :media_uri, :media_uri_https, :uri
17
29
 
18
- # Returns an array of photo sizes
30
+ # Returns a hash of photo sizes
19
31
  #
20
- # @return [Array<Twitter::Size>]
32
+ # @api public
33
+ # @example
34
+ # photo.sizes
35
+ # @return [Hash{Symbol => Twitter::Size}]
21
36
  def sizes
22
- @attrs.fetch(:sizes, []).each_with_object({}) do |(key, value), object|
37
+ result = {} # : Hash[Symbol, Size]
38
+ @attrs.fetch(:sizes, []).each_with_object(result) do |(key, value), object|
23
39
  object[key] = Size.new(value)
24
40
  end
25
41
  end
@@ -4,23 +4,38 @@ require "twitter/media/video_info"
4
4
 
5
5
  module Twitter
6
6
  module Media
7
+ # Represents a Twitter video media object
7
8
  class Video < Twitter::Identity
8
9
  include Memoizable
9
10
 
11
+ # The indices of this media in the text
12
+ #
13
+ # @api public
14
+ # @example
15
+ # video.indices
10
16
  # @return [Array<Integer>]
11
17
  attr_reader :indices
12
18
 
19
+ # The media type
20
+ #
21
+ # @api public
22
+ # @example
23
+ # video.type
13
24
  # @return [String]
14
25
  attr_reader :type
15
26
 
16
27
  display_uri_attr_reader
17
28
  uri_attr_reader :expanded_uri, :media_uri, :media_uri_https, :uri
18
29
 
19
- # Returns an array of photo sizes
30
+ # Returns a hash of video sizes
20
31
  #
21
- # @return [Array<Twitter::Size>]
32
+ # @api public
33
+ # @example
34
+ # video.sizes
35
+ # @return [Hash{Symbol => Twitter::Size}]
22
36
  def sizes
23
- @attrs.fetch(:sizes, []).each_with_object({}) do |(key, value), object|
37
+ result = {} # : Hash[Symbol, Size]
38
+ @attrs.fetch(:sizes, []).each_with_object(result) do |(key, value), object|
24
39
  object[key] = Size.new(value)
25
40
  end
26
41
  end
@@ -28,6 +43,9 @@ module Twitter
28
43
 
29
44
  # Returns video info
30
45
  #
46
+ # @api public
47
+ # @example
48
+ # video.video_info
31
49
  # @return [Twitter::Media::VideoInfo]
32
50
  def video_info
33
51
  VideoInfo.new(@attrs[:video_info]) unless @attrs[:video_info].nil?
@@ -3,17 +3,31 @@ require "twitter/variant"
3
3
 
4
4
  module Twitter
5
5
  module Media
6
+ # Contains video metadata information
6
7
  class VideoInfo < Twitter::Base
7
8
  include Memoizable
8
9
 
9
- # @return [Array<Integer]
10
+ # The aspect ratio of the video
11
+ #
12
+ # @api public
13
+ # @example
14
+ # video_info.aspect_ratio
15
+ # @return [Array<Integer>]
10
16
  attr_reader :aspect_ratio
11
17
 
18
+ # The duration of the video in milliseconds
19
+ #
20
+ # @api public
21
+ # @example
22
+ # video_info.duration_millis
12
23
  # @return [Integer]
13
24
  attr_reader :duration_millis
14
25
 
15
26
  # Returns an array of video variants
16
27
  #
28
+ # @api public
29
+ # @example
30
+ # video_info.variants
17
31
  # @return [Array<Twitter::Variant>]
18
32
  def variants
19
33
  @attrs.fetch(:variants, []).collect do |variant|
@@ -4,12 +4,16 @@ require "twitter/media/photo"
4
4
  require "twitter/media/video"
5
5
 
6
6
  module Twitter
7
+ # Factory for creating media objects based on type
7
8
  class MediaFactory < Twitter::Factory
8
9
  class << self
9
- # Construct a new media object
10
+ # Constructs a new media object
10
11
  #
11
- # @param attrs [Hash]
12
- # @raise [IndexError] Error raised when supplied argument is missing a :type key.
12
+ # @api public
13
+ # @example
14
+ # Twitter::MediaFactory.new(type: "photo", id: 123)
15
+ # @param attrs [Hash] The attributes hash with a :type key
16
+ # @raise [IndexError] Error raised when argument is missing a :type key
13
17
  # @return [Twitter::Media]
14
18
  def new(attrs = {})
15
19
  super(:type, Media, attrs)
@@ -1,7 +1,20 @@
1
1
  require "twitter/base"
2
2
 
3
3
  module Twitter
4
- class Metadata < Twitter::Base
4
+ # Represents metadata about a search result
5
+ class Metadata < Base
6
+ # The ISO language code
7
+ #
8
+ # @api public
9
+ # @example
10
+ # metadata.iso_language_code
11
+ # @return [String]
12
+
13
+ # The result type
14
+ #
15
+ # @api public
16
+ # @example
17
+ # metadata.result_type
5
18
  # @return [String]
6
19
  attr_reader :iso_language_code, :result_type
7
20
  end
@@ -1,7 +1,9 @@
1
1
  require "naught"
2
2
 
3
3
  module Twitter
4
- NullObject = Naught.build do |config| # rubocop:disable Metrics/BlockLength
4
+ # A null object that absorbs all method calls and returns itself
5
+ # @see https://github.com/avdi/naught
6
+ NullObject = Naught.build do |config| # steep:ignore # rubocop:disable Metrics/BlockLength
5
7
  include Comparable
6
8
 
7
9
  config.black_hole
@@ -9,18 +11,18 @@ module Twitter
9
11
  config.define_implicit_conversions
10
12
  config.predicates_return false
11
13
 
12
- def !
14
+ def ! # steep:ignore UndeclaredMethodDefinition
13
15
  true
14
16
  end
15
17
 
16
- def respond_to?(*)
18
+ def respond_to?(*_args) # steep:ignore DifferentMethodParameterKind
17
19
  true
18
20
  end
19
21
 
20
22
  def instance_of?(klass)
21
- raise(TypeError, "class or module required") unless klass.is_a?(Class)
22
-
23
- self.class == klass
23
+ Object.instance_method(:instance_of?).bind_call(self, klass)
24
+ rescue TypeError
25
+ false
24
26
  end
25
27
 
26
28
  def kind_of?(mod)
@@ -31,7 +33,7 @@ module Twitter
31
33
 
32
34
  alias_method :is_a?, :kind_of?
33
35
 
34
- def <=>(other)
36
+ def <=>(other) # steep:ignore MethodBodyTypeMismatch
35
37
  if other.is_a?(self.class)
36
38
  0
37
39
  else
@@ -39,27 +41,27 @@ module Twitter
39
41
  end
40
42
  end
41
43
 
42
- def nil?
44
+ def nil? # steep:ignore MethodBodyTypeMismatch
43
45
  true
44
46
  end
45
47
 
46
- def as_json(*)
48
+ def as_json(*) # steep:ignore UndeclaredMethodDefinition,FallbackAny
47
49
  "null"
48
50
  end
49
51
 
50
- def to_json(*args)
51
- nil.to_json(*args)
52
+ def to_json(*) # steep:ignore UndeclaredMethodDefinition,FallbackAny
53
+ nil.to_json(*) # steep:ignore NoMethod
52
54
  end
53
55
 
54
- def presence
56
+ def presence # steep:ignore UndeclaredMethodDefinition
55
57
  nil
56
58
  end
57
59
 
58
- def blank?
60
+ def blank? # steep:ignore UndeclaredMethodDefinition
59
61
  true
60
62
  end
61
63
 
62
- def present?
64
+ def present? # steep:ignore UndeclaredMethodDefinition
63
65
  false
64
66
  end
65
67
  end
@@ -1,12 +1,66 @@
1
1
  require "twitter/base"
2
2
 
3
3
  module Twitter
4
- class OEmbed < Twitter::Base
4
+ # Represents oEmbed data for a Tweet
5
+ class OEmbed < Base
6
+ # The height of the embedded content
7
+ #
8
+ # @api public
9
+ # @example
10
+ # oembed.height
11
+ # @return [Integer]
12
+
13
+ # The width of the embedded content
14
+ #
15
+ # @api public
16
+ # @example
17
+ # oembed.width
5
18
  # @return [Integer]
6
19
  attr_reader :height, :width
20
+
21
+ # The author name
22
+ #
23
+ # @api public
24
+ # @example
25
+ # oembed.author_name
26
+ # @return [String]
27
+
28
+ # The cache age in seconds
29
+ #
30
+ # @api public
31
+ # @example
32
+ # oembed.cache_age
33
+ # @return [String]
34
+
35
+ # The HTML to embed the Tweet
36
+ #
37
+ # @api public
38
+ # @example
39
+ # oembed.html
40
+ # @return [String]
41
+
42
+ # The provider name
43
+ #
44
+ # @api public
45
+ # @example
46
+ # oembed.provider_name
47
+ # @return [String]
48
+
49
+ # The oEmbed type
50
+ #
51
+ # @api public
52
+ # @example
53
+ # oembed.type
54
+ # @return [String]
55
+
56
+ # The oEmbed version
57
+ #
58
+ # @api public
59
+ # @example
60
+ # oembed.version
7
61
  # @return [String]
8
62
  attr_reader :author_name, :cache_age, :html, :provider_name, :type,
9
- :version
63
+ :version
10
64
 
11
65
  uri_attr_reader :author_uri, :provider_uri, :uri
12
66
  end
data/lib/twitter/place.rb CHANGED
@@ -2,42 +2,110 @@ require "memoizable"
2
2
  require "twitter/identity"
3
3
 
4
4
  module Twitter
5
- class Place < Twitter::Identity
5
+ # Represents a Twitter place
6
+ class Place < Identity
6
7
  include Memoizable
7
8
 
9
+ # The place attributes hash
10
+ #
11
+ # @api public
12
+ # @example
13
+ # place.attributes
8
14
  # @return [Hash]
9
15
  attr_reader :attributes
16
+
17
+ # The country name
18
+ #
19
+ # @api public
20
+ # @example
21
+ # place.country
22
+ # @return [String]
23
+
24
+ # The full name of the place
25
+ #
26
+ # @api public
27
+ # @example
28
+ # place.full_name
29
+ # @return [String]
30
+
31
+ # The place name
32
+ #
33
+ # @api public
34
+ # @example
35
+ # place.name
10
36
  # @return [String]
11
37
  attr_reader :country, :full_name, :name
12
- alias woe_id id
13
- alias woeid id
38
+
39
+ # The Where On Earth ID
40
+ #
41
+ # @!method woe_id
42
+ # @api public
43
+ # @example
44
+ # place.woe_id
45
+ # @return [Integer]
46
+ alias_method :woe_id, :id
47
+
48
+ # The Where On Earth ID
49
+ #
50
+ # @!method woeid
51
+ # @api public
52
+ # @example
53
+ # place.woeid
54
+ # @return [Integer]
55
+ alias_method :woeid, :id
14
56
  object_attr_reader :GeoFactory, :bounding_box
15
57
  object_attr_reader :Place, :contained_within
16
- alias contained? contained_within?
58
+
59
+ # Returns true if this place is contained within another
60
+ #
61
+ # @!method contained?
62
+ # @api public
63
+ # @example
64
+ # place.contained?
65
+ # @return [Boolean]
66
+ alias_method :contained?, :contained_within?
17
67
  uri_attr_reader :uri
18
68
 
19
69
  # Initializes a new place
20
70
  #
21
- # @param attrs [Hash]
22
- # @raise [ArgumentError] Error raised when supplied argument is missing a :woeid key.
71
+ # @api public
72
+ # @example
73
+ # Twitter::Place.new(woeid: 12345)
74
+ # @param attrs [Hash] The attributes hash
75
+ # @raise [ArgumentError] Error raised when argument is missing a :woeid key
23
76
  # @return [Twitter::Place]
24
77
  def initialize(attrs = {})
25
78
  attrs[:id] ||= attrs.fetch(:woeid)
26
79
  super
27
80
  end
28
81
 
82
+ # Returns the country code
83
+ #
84
+ # @api public
85
+ # @example
86
+ # place.country_code
29
87
  # @return [String]
30
88
  def country_code
31
89
  @attrs[:country_code] || @attrs[:countryCode]
32
90
  end
33
91
  memoize :country_code
34
92
 
93
+ # Returns the parent place ID
94
+ #
95
+ # @api public
96
+ # @example
97
+ # place.parent_id
35
98
  # @return [Integer]
36
99
  def parent_id
37
100
  @attrs[:parentid]
38
101
  end
39
102
  memoize :parent_id
40
103
 
104
+ # Returns the place type
105
+ #
106
+ # @api public
107
+ # @example
108
+ # place.place_type
41
109
  # @return [String]
42
110
  def place_type
43
111
  @attrs[:place_type] || (@attrs[:placeType] && @attrs[:placeType][:name])