Class: TopTL::Listing
- Inherits:
-
Object
show all
- Includes:
- Model
- Defined in:
- lib/toptl/types.rb
Instance Attribute Summary
Attributes included from Model
#raw
Class Method Summary
collapse
Methods included from Model
included, #initialize, #to_h
Class Method Details
.from_hash(data) ⇒ Object
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
# File 'lib/toptl/types.rb', line 66
def self.from_hash(data)
data ||= {}
new(
id: (data["id"] || "").to_s,
username: (data["username"] || "").to_s,
title: (data["title"] || "").to_s,
type: (data["type"] || "").to_s,
description: data["description"],
member_count: (data["memberCount"] || 0).to_i,
vote_count: (data["voteCount"] || 0).to_i,
languages: Array(data["languages"]),
verified: data["verified"] == true,
featured: data["featured"] == true,
photo_url: data["photoUrl"],
raw: data
)
end
|