rubyhexagon 2.0.1 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: db0b8e40637feb6bbf0f6a51172e882da9f50302
4
- data.tar.gz: 9313eabbf199ad7131adae13d2c07d7fa898bf1d
2
+ SHA256:
3
+ metadata.gz: 6453fec0dc8f9b3d540143a8936b0763364a4dd5420f1ccbc80009750d682d58
4
+ data.tar.gz: 5b7ea88cfc326811a8685110774c58da34b741c7cfc7de49a5bf76ac23694bd4
5
5
  SHA512:
6
- metadata.gz: 89e0c912d9b3acd09811fb3924af6716c8341effa924853457b44d4354316b05f7358fb337c8d4a1445be40e810d6a17bfbddb6935e8c4064f8755b372a1b60d
7
- data.tar.gz: a383b82a2671b960b96f326667d6bfe552017ad83a6c69cb4807521fcd39283b8a0239f090e6e8e920c055d1e1f599b4cdbf9251d15f5d766e983e7b2e0c749f
6
+ metadata.gz: 5e25bdd04582b1ae1607dd85e27a38311f4095240f1a11aad3eaf5eaa13776e79d9f7073f780663c6b17eb4749e8620589ad01f3e8b334e501fa7799bd9e4674
7
+ data.tar.gz: 8f277204edd5a36565ea9fbbf03f774fd2a718b6230695b135d8084704428f53f4c89f70682307a2db8e7c0efcfd6d6a2d7959f7743d1c0caaf54d07ecbde40a
data/lib/rubyhexagon.rb CHANGED
@@ -25,49 +25,29 @@ require 'tempfile'
25
25
 
26
26
  require_relative 'rubyhexagon/error'
27
27
 
28
- require_relative 'rubyhexagon/artist'
29
28
  require_relative 'rubyhexagon/post'
30
- require_relative 'rubyhexagon/post/flag'
31
- require_relative 'rubyhexagon/post/note'
32
- require_relative 'rubyhexagon/post/tag_item'
33
- require_relative 'rubyhexagon/pool'
34
- require_relative 'rubyhexagon/post/image'
35
- require_relative 'rubyhexagon/tag'
36
- require_relative 'rubyhexagon/tag/alias'
37
- require_relative 'rubyhexagon/tag/implication'
38
- require_relative 'rubyhexagon/tag/type'
39
- require_relative 'rubyhexagon/user'
40
- require_relative 'rubyhexagon/user/level'
29
+ require_relative 'rubyhexagon/post/file'
30
+ require_relative 'rubyhexagon/post/preview'
31
+ require_relative 'rubyhexagon/post/sample'
32
+ require_relative 'rubyhexagon/post/score'
41
33
 
42
34
  # Namespace for all classes in this gem.
43
35
  # @author Maxine Michalski
44
36
  # @since 0.4.3
45
37
  module Rubyhexagon
46
38
  # Major version part
47
- MAJOR = 2
39
+ MAJOR = 3
48
40
  # Minor version part
49
41
  MINOR = 0
50
42
  # Patch version part
51
- PATCH = 1
43
+ PATCH = 0
52
44
  # Name of gem
53
45
  NAME = 'rubyhexagon'
54
46
  # Full version string
55
47
  VERSION = "#{MAJOR}.#{MINOR}.#{PATCH}"
56
48
  end
57
49
 
58
- # Compatibility assignment, so that I can move module to a new name and don't
59
- # break old code.
60
- # Both module names can be used.
61
50
  E621 = Rubyhexagon
62
51
 
63
52
  require_relative 'rubyhexagon/api'
64
- require_relative 'rubyhexagon/api/artist'
65
53
  require_relative 'rubyhexagon/api/post'
66
- require_relative 'rubyhexagon/api/post/flag'
67
- require_relative 'rubyhexagon/api/post/note'
68
- require_relative 'rubyhexagon/api/post/tag_item'
69
- require_relative 'rubyhexagon/api/pool'
70
- require_relative 'rubyhexagon/api/tag'
71
- require_relative 'rubyhexagon/api/tag/alias'
72
- require_relative 'rubyhexagon/api/tag/implication'
73
- require_relative 'rubyhexagon/api/user'
@@ -41,16 +41,23 @@ module Rubyhexagon
41
41
  # @param query [Hash] query hash for interface
42
42
  #
43
43
  # @return [Hash|Array] A decoded JSON string
44
- def self.fetch(noun, action, query)
45
- unless noun.is_a?(Symbol) && action.is_a?(Symbol) && query.is_a?(Hash)
46
- raise ArgumentError, 'Two symbols and a hash are required!'
44
+ def self.fetch(noun, query)
45
+ unless noun.is_a?(Symbol) && query.is_a?(Hash)
46
+ raise ArgumentError, 'A symbol and a hash are required!'
47
47
  end
48
48
  http = Net::HTTP.new('e621.net', 443)
49
49
  http.use_ssl = true
50
- query = query.map { |k, v| "#{k}=#{v}" }.join('&')
51
- lock do
52
- data = http.get("/#{noun}/#{action}.json?#{query}", USER_AGENT).body
53
- JSON.parse(data, symbolize_names: true)
50
+ if query.key?(:id)
51
+ lock do
52
+ data = http.get("/#{noun}/#{query[:id]}.json", USER_AGENT).body
53
+ JSON.parse(data, symbolize_names: true)
54
+ end
55
+ else
56
+ query = query.map { |k, v| "#{k}=#{v}" }.join('&')
57
+ lock do
58
+ data = http.get("/#{noun}.json?#{query}", USER_AGENT).body
59
+ JSON.parse(data, symbolize_names: true)
60
+ end
54
61
  end
55
62
  end
56
63
 
@@ -38,28 +38,7 @@ module Rubyhexagon
38
38
  raise ArgumentError, 'A Hash or post data object are required'
39
39
  end
40
40
  id = post.is_a?(Hash) ? post[:id] : post.id
41
- new(E621::API.fetch(:post, :show, id: id))
42
- end
43
-
44
- # @author Maxine Michalski
45
- #
46
- # Fetch tag information
47
- #
48
- # @note This method fetches complete tag information for a post
49
- # @param post [Hash|E621::Post] User data to fetch from
50
- # @example Get tags for post
51
- # E621::Post.tags(id: 1) #=> Array<E621::Tag>
52
- # @return [Array<E621::Tag>]
53
- # @see https://e621.net/help/show/api#posts
54
- def self.tags(post)
55
- unless (post.is_a?(Hash) && post[:id].is_a?(Integer)) ||
56
- post.is_a?(E621::Post)
57
- raise ArgumentError, 'A Hash or post data object are required'
58
- end
59
- id = post.is_a?(Hash) ? post[:id] : post.id
60
- E621::API.fetch(:post, :tags, id: id).map do |t|
61
- E621::Tag.new(t)
62
- end
41
+ new(E621::API.fetch(:posts, id: id)[:post])
63
42
  end
64
43
 
65
44
  # @author Maxine Michalski
@@ -72,39 +51,7 @@ module Rubyhexagon
72
51
  # @see https://e621.net/help/show/api#posts
73
52
  def self.list(query)
74
53
  raise ArgumentError, 'A Hash is required' unless query.is_a?(Hash)
75
- E621::API.fetch(:post, :index, query).map do |post|
76
- new(post)
77
- end
78
- end
79
-
80
- # @author Maxine Michalski
81
- #
82
- # Fetch a list of deleted posts
83
- #
84
- # @example Get a list of deleted posts
85
- # E621::Post.deleted(page: 1) #=> Array<E621::Post>
86
- # @return [Array<E621::Post>]
87
- # @see https://e621.net/help/show/api#posts
88
- def self.deleted(query)
89
- raise ArgumentError, 'A Hash is required' unless query.is_a?(Hash)
90
- E621::API.fetch(:post, :deleted_index, query).map do |post|
91
- new(post)
92
- end
93
- end
94
-
95
- # @author Maxine Michalski
96
- #
97
- # Fetch a list of popular posts
98
- #
99
- # @example Get popular posts, by day
100
- # E621::Post.popular_by(:day) #=> E621::Post
101
- # @return [Array<E621::Post>]
102
- # @see https://e621.net/help/show/api#posts
103
- def self.popular_by(period)
104
- unless %i[day week month].include?(period)
105
- raise ArgumentError, 'Period must be day, week or month'
106
- end
107
- E621::API.fetch(:post, "popular_by_#{period}".to_sym, {}).map do |post|
54
+ E621::API.fetch(:posts, query)[:posts].map do |post|
108
55
  new(post)
109
56
  end
110
57
  end
@@ -118,7 +65,7 @@ module Rubyhexagon
118
65
  # @return [E621::Post]
119
66
  # @see https://e621.net/help/show/api#posts
120
67
  def show
121
- E621::Post.new(E621::API.fetch(:post, :show, id: @id))
68
+ E621::Post.new(E621::API.fetch(:posts, id: @id)[:post])
122
69
  end
123
70
 
124
71
  # @author Maxine Michalski
@@ -129,24 +76,10 @@ module Rubyhexagon
129
76
  # post.download(:image) #=> Tempfile
130
77
  # @return [Tempfile]
131
78
  def download(which)
132
- unless %i[image preview sample].include?(which)
79
+ unless %i[file preview sample].include?(which)
133
80
  raise ArgumentError, 'Unsupported doanload'
134
81
  end
135
82
  E621::API.download(__send__(which).url)
136
83
  end
137
-
138
- # @author Maxine Michalski
139
- #
140
- # List of notes, that belong to a post
141
- #
142
- # @example Get nots for a post
143
- # post.notes #=> Array<E621::Post::Note>
144
- # @return [E621::Post::Note]
145
- # @see https://e621.net/help/show/api#notes
146
- def notes
147
- E621::API.fetch(:note, :index, post_id: @id).map do |n|
148
- E621::Post::Note.new(n)
149
- end
150
- end
151
84
  end
152
85
  end
@@ -30,113 +30,54 @@ module Rubyhexagon
30
30
  # @return [Integer] id of post information
31
31
  attr_reader :id
32
32
 
33
- # Post author
34
- # @example Get post creator
35
- # post.author #=> E621::User
36
- # @return [E621::User] user object of who uploaded this post
37
- attr_reader :author
38
-
39
33
  # Time post was created at
40
34
  # @example Get creation time
41
35
  # post.created_at #=> Time
42
36
  # @return [Time] creation time of post
43
37
  attr_reader :created_at
44
38
 
45
- # Post status
46
- # @example Get post status
47
- # post.status #=> Symbol
48
- # @return [Symbol] status of post, can be :active, :flagged, :pending or
49
- # :deleted
50
- attr_reader :status
51
-
52
- # Post sources
53
- # @example Get post sources
54
- # post.sources #=> Array<String>
55
- # @return [Array<String>] array of sources. This can contain URI in string
56
- # form
57
- attr_reader :sources
39
+ # Time post was last updated
40
+ # @example Get last update time
41
+ # post.updated_at #=> Time
42
+ # @return [Time] last update time of post
43
+ attr_reader :updated_at
58
44
 
59
- # Post artists
60
- #
61
- # @example Get post artists
62
- # post.artists #=> Array<E621::Artist>
63
- # @return [Array<E621::Artist>] array of artists, that work on the image
64
- # in this post
65
- attr_reader :artists
45
+ # File of post
46
+ # @example Get post's file
47
+ # post.file #=> E621::Post::File
48
+ # @return [E621::Post::File] file content of this post
49
+ attr_reader :file
66
50
 
67
- # Post desciption
68
- # @example Get post description
69
- # post.description #=> String|nil
70
- # @return [String|NilClass] description that's associated with this post
71
- attr_reader :description
51
+ # Preview of post
52
+ # @example Get post's preview
53
+ # post.preview #=> E621::Post::Preview
54
+ # @return [E621::Post::Preview] preview content of this post
55
+ attr_reader :preview
72
56
 
73
- # Count of users who favorited this post
74
- # @example Get favorite count
75
- # post.fav_count #=> Integer
76
- # @return [Integer] number of people, who favorited this post
77
- attr_reader :fav_count
57
+ # Sample of post
58
+ # @example Get post's sample
59
+ # post.sample #=> E621::Post::Sample
60
+ # @return [E621::Post::Sample] sample content of this post
61
+ attr_reader :sample
78
62
 
79
- # Post score
80
- # @example Get score assigned to post
81
- # post.score #=> Integer
82
- # @return [Integer] vote score this post holds
63
+ # Score for post
64
+ # @example Get post's score
65
+ # post.score #=> E621::Post::Score
66
+ # @return [E621::Post::Score] score information of this post
83
67
  attr_reader :score
84
68
 
85
- # Post rating
86
- # @example Get post rating
87
- # post.rating #=> Symbol
88
- # @return [Symbol] rating of this post. Can be one of :safe,
89
- # :questionable, :explicit
69
+ attr_reader :tags
70
+ attr_reader :locked_tags
71
+ attr_reader :change_seq
90
72
  attr_reader :rating
91
-
92
- # Post parent
93
- # @example Get parent of post
94
- # post.parent #=> E621::Post or nil
95
- # @return [E621:post] parent of this post
96
- # @return [NilClass]
73
+ attr_reader :fav_count
74
+ attr_reader :sources
97
75
  attr_reader :parent
98
-
99
- # Post children
100
- # @example Get post's children
101
- # post.children #=> [] or Array<E621::Post>
102
- # @return [Array<E621::Post>] Array of child posts
103
76
  attr_reader :children
104
-
105
- # Post MD5 checksum
106
- # @example Get post's MD5 checksum
107
- # post.md5 #=> String
108
- # @return [String] MD5 checksum associated with this post
109
- attr_reader :md5
110
-
111
- # Image of post
112
- # @example Get post's image
113
- # post.image #=> E621::Image
114
- # @return [E621::Image] file content of this post
115
- attr_reader :image
116
-
117
- # Sample of post
118
- # @example Get post's image
119
- # post.sample #=> E621::Sample
120
- # @return [E621::Sample] sample data in E621::Sample format
121
- attr_reader :sample
122
-
123
- # Preview of post
124
- # @example Get post's image
125
- # post.preview #=> E621::Preview
126
- # @return [E621::Preview] preview data in E621::Preview format
127
- attr_reader :preview
128
-
129
- # Deletion reason of post, if any
130
- # @example Get deletion reason of post
131
- # post.delreason #=> String or nil
132
- # @return [String|NilClass] reason for deletion, if deleted
133
- attr_reader :delreason
134
-
135
- # Tags of post
136
- # @example Get tags of post, without web interaction
137
- # post.tags #=> Array<E621::Tag>
138
- # @return [Array<E621::Tag>] tags of this post
139
- attr_reader :tags
77
+ attr_reader :approver
78
+ attr_reader :uploader
79
+ attr_reader :description
80
+ attr_reader :comment_count
140
81
 
141
82
  # @author Maxine Michalski
142
83
  #
@@ -148,88 +89,19 @@ module Rubyhexagon
148
89
  # @return the object
149
90
  def initialize(post)
150
91
  raise ArgumentError, "#{post.class} is not a Hash" unless post.is_a?(Hash)
92
+ raise ArgumentError, 'Not a proper post Hash' if post.key?(:post)
151
93
  post[:id] = post[:id].to_i
152
94
  id = post[:id]
153
95
  raise InvalidIDError, "ID out of range: #{id}" unless id.positive?
154
96
  post.each do |k, v|
155
- if %i[rating created_at status sources parent_id children
156
- description artist tags].include?(k)
97
+ if %i[created_at updated_at file sample preview score flags
98
+ rating relationships].include?(k)
157
99
  __send__("setup_#{k}".to_sym, v)
158
- elsif %i[id description score fav_count md5 has_comments has_children
159
- delreason has_notes].include?(k)
160
- instance_variable_set("@#{k}".to_sym, v)
100
+ elsif %i[id tags change_seq sources fav_count description
101
+ comment_count is_favorited].include?(k)
102
+ instance_variable_set("@#{k}", v)
161
103
  end
162
104
  end
163
- setup_author(post)
164
- setup_files(post)
165
- end
166
-
167
- # @author Maxine Michalski
168
- #
169
- # Test status with an optional parameter
170
- #
171
- # @param test_var [Symbol] variable under test
172
- # @api private
173
- # @example Get rating status
174
- # post.explicit? #=> true or false
175
- # @return [TrueClass|FalseClass]
176
- def test(test_var = nil)
177
- test_var ||= __callee__.to_s.sub(/\?/, '').to_sym
178
- test_ar = %i[safe questionable explicit]
179
- test_ar.include?(test_var) ? @rating == test_var : @status == test_var
180
- end
181
- # @see test
182
- # @api public
183
- alias active? test
184
- # @api public
185
- # @see test
186
- alias flagged? test
187
- # @api public
188
- # @see test
189
- alias pending? test
190
- # @api public
191
- # @see test
192
- alias deleted? test
193
- # @api public
194
- # @see test
195
- alias safe? test
196
- # @api public
197
- # @see test
198
- alias questionable? test
199
- # @api public
200
- # @see test
201
- alias explicit? test
202
-
203
- # @author Maxine Michalski
204
- #
205
- # Show if post has comments or not
206
- # @example Get if post has comments
207
- # post.comments? #=> true or false
208
- # @return [TrueClass|FalseClass]
209
- def comments?
210
- return false if @has_comments.nil?
211
- @has_comments
212
- end
213
-
214
- # @author Maxine Michalski
215
- #
216
- # Show if post has a parent
217
- # @example Has post a parent?
218
- # post.parent? #=> true or false
219
- # @return [TrueClass|FalseClass]
220
- def parent?
221
- !@parent.nil?
222
- end
223
-
224
- # @author Maxine Michalski
225
- #
226
- # Show if post has children
227
- # @example Has post children?
228
- # post.children? #=> true or false
229
- # @return [TrueClass|FalseClass]
230
- def children?
231
- return false if @has_children.nil?
232
- @has_children
233
105
  end
234
106
 
235
107
  # @author Maxine Michalski
@@ -242,16 +114,6 @@ module Rubyhexagon
242
114
  other.is_a?(Post) && @id == other.id
243
115
  end
244
116
 
245
- # @author Maxine Michalski
246
- #
247
- # Has post notes?
248
- # @example Post has notes?
249
- # post.notes? #=> true or false
250
- # @return [TrueClass|FalseClass]
251
- def notes?
252
- @has_notes
253
- end
254
-
255
117
  # @author Maxine Michalski
256
118
  #
257
119
  # Turn object into a hash representation of itself
@@ -267,18 +129,41 @@ module Rubyhexagon
267
129
  hash
268
130
  end
269
131
 
270
- private
132
+ def test
133
+ instance_variable_get("@#{__callee__.to_s.sub('?', '')}")
134
+ end
271
135
 
272
- # @author Maxine Michalski
273
- #
274
- # Set author information
275
- # @api private
276
- # @param post [Hash] post data
277
- # @return [E621::User]
278
- def setup_author(post)
279
- return if post[:creator_id].nil?
280
- @author = E621::User.new(id: post[:creator_id], name: post[:author])
136
+ alias pending? test
137
+ alias flagged? test
138
+ alias note_locked? test
139
+ alias status_locked? test
140
+ alias rating_locked? test
141
+ alias deleted? test
142
+
143
+ def safe?
144
+ @rating == :safe
145
+ end
146
+
147
+ def questionable?
148
+ @rating == :questionable
149
+ end
150
+
151
+ def explicit?
152
+ @rating == :explicit
153
+ end
154
+
155
+ def children?
156
+ @has_children
157
+ end
158
+
159
+ def active_children?
160
+ @has_active_children
161
+ end
162
+
163
+ def favorited?
164
+ @is_favorited
281
165
  end
166
+ private
282
167
 
283
168
  # @author Maxine Michalski
284
169
  #
@@ -299,111 +184,80 @@ module Rubyhexagon
299
184
  # Set creation time
300
185
  #
301
186
  # @api private
302
- # @param time [Time] Hash that includes creation time in UNIX Epoch on an
303
- # `:s` key
187
+ # @param time [String] Hash that includes creation time
304
188
  # @return [Time]
305
189
  def setup_created_at(time)
306
- @created_at = Time.at(time[:s]) unless time.nil?
190
+ @created_at = Time.parse(time) unless time.nil?
307
191
  end
308
192
 
309
193
  # @author Maxine Michalski
310
194
  #
311
- # Set status of post
312
- # @api private
313
- # @param status [String] Status of post
314
- # @return [Symbol]
315
- def setup_status(status)
316
- @status = status.to_sym unless status.nil?
317
- end
318
-
319
- # @author Maxine Michalski
195
+ # Set update time
320
196
  #
321
- # Set sources of post
322
197
  # @api private
323
- # @param sources [Array<String>] Sources of post
324
- # @return [Array<String>]
325
- def setup_sources(sources)
326
- @sources = sources.nil? ? [] : sources
198
+ # @param time [String] Hash that includes update time
199
+ # @return [Time]
200
+ def setup_updated_at(time)
201
+ @updated_at = Time.parse(time) unless time.nil?
327
202
  end
328
203
 
329
204
  # @author Maxine Michalski
330
205
  #
331
- # Set parent post
206
+ # Set file information
332
207
  #
333
- # @param parent [Integer] Parent post ID
334
208
  # @api private
335
- # @note A parent post is only set with an ID and further information must
336
- # be fetched manually.
337
- # @return [E621::Post|NilClass]
338
- def setup_parent_id(parent)
339
- @parent = parent.nil? ? nil : E621::Post.new(id: parent)
209
+ # @param file [Hash] Information about post file
210
+ # @return [E621::Post::File]
211
+ def setup_file(file)
212
+ @file = E621::Post::File.new(file)
340
213
  end
341
214
 
342
215
  # @author Maxine Michalski
343
216
  #
344
- # Set children posts
217
+ # Set sample information
345
218
  #
346
- # @param children [Array<Integer>] Children post IDs
347
219
  # @api private
348
- # @note All children are only set with an ID and further information must
349
- # be fetched manually.
350
- # @return [Array<E621::Post>]
351
- def setup_children(children)
352
- return [] if children.nil?
353
- @children = children.split(',').map { |c| E621::Post.new(id: c) }
220
+ # @param sample [Hash] Information about post sample
221
+ # @return [E621::Post::Sample]
222
+ def setup_sample(sample)
223
+ @sample = E621::Post::Sample.new(sample)
354
224
  end
355
225
 
356
226
  # @author Maxine Michalski
357
227
  #
358
- # Set post description
228
+ # Set preview information
359
229
  #
360
- # @param description [String] Post description
361
230
  # @api private
362
- # @note Empty descriptions are set to nil
363
- # @return [String|NilClass]
364
- def setup_description(description)
365
- @description = !description.nil? && description.empty? ? nil : description
231
+ # @param preview [Hash] Information about post preview
232
+ # @return [E621::Post::Preview]
233
+ def setup_preview(preview)
234
+ @preview = E621::Post::Preview.new(preview)
366
235
  end
367
-
236
+
368
237
  # @author Maxine Michalski
369
238
  #
370
- # Setup artist for post
239
+ # Set score information
371
240
  #
372
- # @param artists [Array<String>] array of artist names
373
241
  # @api private
374
- # @return [Array<E621::Artist>]
375
- def setup_artist(artists)
376
- @artists = artists.map { |a| E621::Artist.new(name: CGI.unescape(a)) }
242
+ # @param score [Hash] Information about post score
243
+ # @return [E621::Post::Score]
244
+ def setup_score(score)
245
+ @score = E621::Post::Score.new(score)
377
246
  end
378
247
 
379
- # @author Maxine Michalski
380
- #
381
- # Setup tags for post
382
- # @param tags [String] String that contains tags, separated by spaces
383
- # @api private
384
- # @note These tags can only be read by #tags
385
- # @return [Array<E621::Tag>
386
- def setup_tags(tags)
387
- @tags = tags.split(' ').map { |t| E621::Tag.new(name: t) }
248
+ def setup_flags(flags)
249
+ flags.each do |k, v|
250
+ instance_variable_set("@#{k}", v)
251
+ end
388
252
  end
389
253
 
390
- # @author Maxine Michalski
391
- #
392
- # Setup files for posts
393
- # @param post [Hash] post data
394
- # @api private
395
- # @return [E621::Post::Image|E621::Post::Sample|E621::Post::Preview]
396
- def setup_files(post)
397
- return if post[:file_url].nil?
398
- @image = Image.new(url: post[:file_url], ext: post[:file_ext],
399
- width: post[:width], height: post[:height],
400
- size: post[:file_size])
401
- @sample = Sample.new(url: post[:sample_url], ext: post[:file_ext],
402
- width: post[:sample_width],
403
- height: post[:sample_height], size: 0)
404
- @preview = Preview.new(url: post[:preview_url], ext: 'jpg',
405
- width: post[:preview_width],
406
- height: post[:preview_height], size: 0)
254
+ def setup_relationships(rel)
255
+ @parent = rel[:parent_id].nil? ? nil : E621::Post.new(id: rel[:parent_id])
256
+ @has_children = rel[:has_children]
257
+ @has_active_children = rel[:has_active_children]
258
+ @children = rel[:children].map do |c|
259
+ E621::Post.new(id: c)
260
+ end
407
261
  end
408
262
  end
409
263
  end