Class: E621ExportDownloader::Models::Post

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/e621_export_downloader/models/post.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(record) ⇒ Post

Returns a new instance of Post.



106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
# File 'lib/e621_export_downloader/models/post.rb', line 106

def initialize(record)
  @record = T.let(record, T::Hash[String, String])
  @approver_id       = T.let(T.must(record["approver_id"]).empty? ? nil : record["approver_id"].to_i, T.nilable(Integer))
  @bg_color          = T.let(T.must(record["bg_color"]).empty? ? nil : record["bg_color"], T.nilable(String))
  @change_seq        = T.let(record["change_seq"].to_i, Integer)
  @comment_count     = T.let(record["comment_count"].to_i, Integer)
  @created_at        = T.let(DateTime.parse(record["created_at"]), DateTime)
  @description       = T.let(T.must(record["description"]).gsub("\r\n", "\n"), String)
  @down_score        = T.let(record["down_score"].to_i, Integer)
  @duration          = T.let(T.must(record["duration"]).empty? ? nil : record["duration"].to_f, T.nilable(Float))
  @fav_count         = T.let(record["fav_count"].to_i, Integer)
  @file_ext          = T.let(T.must(record["file_ext"]), String)
  @file_size         = T.let(record["file_size"].to_i, Integer)
  @id                = T.let(record["id"].to_i, Integer)
  @image_height      = T.let(record["image_height"].to_i, Integer)
  @image_width       = T.let(record["image_width"].to_i, Integer)
  @is_deleted        = T.let(record["is_deleted"] == "t", T::Boolean)
  @is_flagged        = T.let(record["is_flagged"] == "t", T::Boolean)
  @is_note_locked    = T.let(record["is_note_locked"] == "t", T::Boolean)
  @is_pending        = T.let(record["is_pending"] == "t", T::Boolean)
  @is_rating_locked  = T.let(record["is_rating_locked"] == "t", T::Boolean)
  @is_status_locked  = T.let(record["is_status_locked"] == "t", T::Boolean)
  @last_commented_at = T.let(T.must(record["last_commented_at"]).empty? ? nil : DateTime.parse(record["last_commented_at"]), T.nilable(DateTime))
  @last_noted_at     = T.let(T.must(record["last_noted_at"]).empty? ? nil : DateTime.parse(record["last_noted_at"]), T.nilable(DateTime))
  @locked_tags       = T.let(T.must(record["locked_tags"]), String)
  @md5               = T.let(T.must(record["md5"]).empty? ? nil : record["md5"], T.nilable(String))
  @parent_id         = T.let(T.must(record["parent_id"]).empty? ? nil : record["parent_id"].to_i, T.nilable(Integer))
  @rating            = T.let(T.must(record["rating"]), String)
  @score             = T.let(record["score"].to_i, Integer)
  @sources           = T.let(T.must(record["source"]).gsub("\r\n", "\n").split("\n"), T::Array[String])
  @tags              = T.let(T.must(record["tag_string"]).split, T::Array[String])
  @up_score          = T.let(record["up_score"].to_i, Integer)
  @updated_at        = T.let(T.must(record["updated_at"]).empty? ? nil : DateTime.parse(record["updated_at"]), T.nilable(DateTime))
  @uploader_id       = T.let(T.must(record["uploader_id"]).empty? ? nil : record["uploader_id"].to_i, T.nilable(Integer))
end

Instance Attribute Details

#approver_idObject (readonly)

Returns the value of attribute approver_id.



10
11
12
# File 'lib/e621_export_downloader/models/post.rb', line 10

def approver_id
  @approver_id
end

#bg_colorObject (readonly)

Returns the value of attribute bg_color.



13
14
15
# File 'lib/e621_export_downloader/models/post.rb', line 13

def bg_color
  @bg_color
end

#change_seqObject (readonly)

Returns the value of attribute change_seq.



16
17
18
# File 'lib/e621_export_downloader/models/post.rb', line 16

def change_seq
  @change_seq
end

#comment_countObject (readonly)

Returns the value of attribute comment_count.



19
20
21
# File 'lib/e621_export_downloader/models/post.rb', line 19

def comment_count
  @comment_count
end

#created_atObject (readonly)

Returns the value of attribute created_at.



22
23
24
# File 'lib/e621_export_downloader/models/post.rb', line 22

def created_at
  @created_at
end

#descriptionObject (readonly)

Returns the value of attribute description.



25
26
27
# File 'lib/e621_export_downloader/models/post.rb', line 25

def description
  @description
end

#down_scoreObject (readonly)

Returns the value of attribute down_score.



28
29
30
# File 'lib/e621_export_downloader/models/post.rb', line 28

def down_score
  @down_score
end

#durationObject (readonly)

Returns the value of attribute duration.



31
32
33
# File 'lib/e621_export_downloader/models/post.rb', line 31

def duration
  @duration
end

#fav_countObject (readonly)

Returns the value of attribute fav_count.



34
35
36
# File 'lib/e621_export_downloader/models/post.rb', line 34

def fav_count
  @fav_count
end

#file_extObject (readonly)

Returns the value of attribute file_ext.



37
38
39
# File 'lib/e621_export_downloader/models/post.rb', line 37

def file_ext
  @file_ext
end

#file_sizeObject (readonly)

Returns the value of attribute file_size.



40
41
42
# File 'lib/e621_export_downloader/models/post.rb', line 40

def file_size
  @file_size
end

#idObject (readonly)

Returns the value of attribute id.



43
44
45
# File 'lib/e621_export_downloader/models/post.rb', line 43

def id
  @id
end

#image_heightObject (readonly)

Returns the value of attribute image_height.



46
47
48
# File 'lib/e621_export_downloader/models/post.rb', line 46

def image_height
  @image_height
end

#image_widthObject (readonly)

Returns the value of attribute image_width.



49
50
51
# File 'lib/e621_export_downloader/models/post.rb', line 49

def image_width
  @image_width
end

#is_deletedObject (readonly)

Returns the value of attribute is_deleted.



52
53
54
# File 'lib/e621_export_downloader/models/post.rb', line 52

def is_deleted
  @is_deleted
end

#is_flaggedObject (readonly)

Returns the value of attribute is_flagged.



55
56
57
# File 'lib/e621_export_downloader/models/post.rb', line 55

def is_flagged
  @is_flagged
end

#is_note_lockedObject (readonly)

Returns the value of attribute is_note_locked.



58
59
60
# File 'lib/e621_export_downloader/models/post.rb', line 58

def is_note_locked
  @is_note_locked
end

#is_pendingObject (readonly)

Returns the value of attribute is_pending.



61
62
63
# File 'lib/e621_export_downloader/models/post.rb', line 61

def is_pending
  @is_pending
end

#is_rating_lockedObject (readonly)

Returns the value of attribute is_rating_locked.



64
65
66
# File 'lib/e621_export_downloader/models/post.rb', line 64

def is_rating_locked
  @is_rating_locked
end

#is_status_lockedObject (readonly)

Returns the value of attribute is_status_locked.



67
68
69
# File 'lib/e621_export_downloader/models/post.rb', line 67

def is_status_locked
  @is_status_locked
end

#last_commented_atObject (readonly)

Returns the value of attribute last_commented_at.



70
71
72
# File 'lib/e621_export_downloader/models/post.rb', line 70

def last_commented_at
  @last_commented_at
end

#last_noted_atObject (readonly)

Returns the value of attribute last_noted_at.



73
74
75
# File 'lib/e621_export_downloader/models/post.rb', line 73

def last_noted_at
  @last_noted_at
end

#locked_tagsObject (readonly)

Returns the value of attribute locked_tags.



76
77
78
# File 'lib/e621_export_downloader/models/post.rb', line 76

def locked_tags
  @locked_tags
end

#md5Object (readonly)

Returns the value of attribute md5.



79
80
81
# File 'lib/e621_export_downloader/models/post.rb', line 79

def md5
  @md5
end

#parent_idObject (readonly)

Returns the value of attribute parent_id.



82
83
84
# File 'lib/e621_export_downloader/models/post.rb', line 82

def parent_id
  @parent_id
end

#ratingObject (readonly)

Returns the value of attribute rating.



85
86
87
# File 'lib/e621_export_downloader/models/post.rb', line 85

def rating
  @rating
end

#scoreObject (readonly)

Returns the value of attribute score.



88
89
90
# File 'lib/e621_export_downloader/models/post.rb', line 88

def score
  @score
end

#sourcesObject (readonly)

Returns the value of attribute sources.



91
92
93
# File 'lib/e621_export_downloader/models/post.rb', line 91

def sources
  @sources
end

#tagsObject (readonly)

Returns the value of attribute tags.



94
95
96
# File 'lib/e621_export_downloader/models/post.rb', line 94

def tags
  @tags
end

#up_scoreObject (readonly)

Returns the value of attribute up_score.



97
98
99
# File 'lib/e621_export_downloader/models/post.rb', line 97

def up_score
  @up_score
end

#updated_atObject (readonly)

Returns the value of attribute updated_at.



100
101
102
# File 'lib/e621_export_downloader/models/post.rb', line 100

def updated_at
  @updated_at
end

#uploader_idObject (readonly)

Returns the value of attribute uploader_id.



103
104
105
# File 'lib/e621_export_downloader/models/post.rb', line 103

def uploader_id
  @uploader_id
end

Instance Method Details

#to_json(*_args) ⇒ Object



143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
# File 'lib/e621_export_downloader/models/post.rb', line 143

def to_json(*_args)
  {
    approver_id:       @approver_id,
    bg_color:          @bg_color,
    change_seq:        @change_seq,
    comment_count:     @comment_count,
    created_at:        @created_at,
    description:       @description,
    down_score:        @down_score,
    duration:          @duration,
    fav_count:         @fav_count,
    file_ext:          @file_ext,
    file_size:         @file_size,
    id:                @id,
    image_height:      @image_height,
    image_width:       @image_width,
    is_deleted:        @is_deleted,
    is_flagged:        @is_flagged,
    is_note_locked:    @is_note_locked,
    is_pending:        @is_pending,
    is_rating_locked:  @is_rating_locked,
    is_status_locked:  @is_status_locked,
    last_commented_at: @last_commented_at,
    last_noted_at:     @last_noted_at,
    locked_tags:       @locked_tags,
    md5:               @md5,
    parent_id:         @parent_id,
    rating:            @rating,
    score:             @score,
    sources:           @sources,
    tags:              @tags,
    up_score:          @up_score,
    updated_at:        @updated_at,
    uploader_id:       @uploader_id,
  }.to_json
end