Method: Faker::Twitter.status

Defined in:
lib/faker/default/twitter.rb

.status(include_user: true, include_photo: false) ⇒ Hash

Produces a random Twitter user.

Examples:

Faker::Twitter.status #=> {:id=>8821452687517076614, :text=>"Ea et laboriosam vel non."...
Faker::Twitter.status(include_user: false) # Just get a status object with no embed user
Faker::Twitter.status(include_photo: true) # Includes entities for an attached image

Parameters:

  • include_user (Boolean) (defaults to: true)

    Include or exclude user details

  • include_photo (Boolean) (defaults to: false)

    Include or exclude user photo

Returns:

  • (Hash)


86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
# File 'lib/faker/default/twitter.rb', line 86

def status(include_user: true, include_photo: false)
  warn('DEPRECATION WARNING: Faker::Twitter is deprecated. Use Faker::X instead. Some return attributes \
    will be removed, check the docs for more details.')

  status_id = id
  status = {
    id: status_id,
    id_str: status_id.to_s,
    contributors: nil,
    coordinates: nil,
    created_at: created_at,
    entities: status_entities(include_photo: include_photo),
    favorite_count: Faker::Number.between(to: 1, from: 10_000),
    favorited: false,
    geo: nil,
    in_reply_to_screen_name: nil,
    in_reply_to_status_id: nil,
    in_reply_to_user_id_str: nil,
    in_reply_to_user_id: nil,
    is_quote_status: false,
    lang: Faker::Address.country_code,
    nil: nil,
    place: nil,
    possibly_sensitive: Faker::Boolean.boolean(true_ratio: 0.1),
    retweet_count: Faker::Number.between(to: 1, from: 10_000),
    retweeted_status: nil,
    retweeted: false,
    source: "<a href=\"#{Faker::Internet.url(host: 'example.com')}\" rel=\"nofollow\">#{Faker::Company.name}</a>",
    text: Faker::Lorem.sentence,
    truncated: false
  }
  status[:user] = Faker::Twitter.user(include_status: false) if include_user
  status[:text] = "#{status[:text]} #{status[:entities][:media].first[:url]}" if include_photo
  status
end