Class: E621ExportDownloader::Models::Artist

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(record) ⇒ Artist

Returns a new instance of Artist.



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/e621_export_downloader/models/artist.rb', line 46

def initialize(record)
  @record = T.let(record, T::Hash[String, String])
  @active_urls    = T.let(T.must(record["active_urls"]).split("\n"), T::Array[String])
  @created_at     = T.let(DateTime.parse(record["created_at"]), DateTime)
  @creator_id     = T.let(record["creator_id"].to_i, Integer)
  @group_name     = T.let(T.must(record["group_name"]).empty? ? nil : record["group_name"], T.nilable(String))
  @id             = T.let(record["id"].to_i, Integer)
  @inactive_urls  = T.let(T.must(record["inactive_urls"]).split("\n"), T::Array[String])
  @is_active      = T.let(record["is_active"] == "t", T::Boolean)
  @is_locked      = T.let(record["is_locked"] == "t", T::Boolean)
  @linked_user_id = T.let(T.must(record["linked_user_id"]).empty? ? nil : record["linked_user_id"].to_i, T.nilable(Integer))
  @name           = T.let(T.must(record["name"]), String)
  inner           = T.must(T.must(record["other_names"])[1..-2])
  @other_names    = T.let(inner.empty? ? [] : inner.split(","), T::Array[String])
  @updated_at     = T.let(DateTime.parse(record["updated_at"]), DateTime)
end

Instance Attribute Details

#active_urlsObject (readonly)

Returns the value of attribute active_urls.



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

def active_urls
  @active_urls
end

#created_atObject (readonly)

Returns the value of attribute created_at.



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

def created_at
  @created_at
end

#creator_idObject (readonly)

Returns the value of attribute creator_id.



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

def creator_id
  @creator_id
end

#group_nameObject (readonly)

Returns the value of attribute group_name.



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

def group_name
  @group_name
end

#idObject (readonly)

Returns the value of attribute id.



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

def id
  @id
end

#inactive_urlsObject (readonly)

Returns the value of attribute inactive_urls.



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

def inactive_urls
  @inactive_urls
end

#is_activeObject (readonly)

Returns the value of attribute is_active.



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

def is_active
  @is_active
end

#is_lockedObject (readonly)

Returns the value of attribute is_locked.



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

def is_locked
  @is_locked
end

#linked_user_idObject (readonly)

Returns the value of attribute linked_user_id.



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

def linked_user_id
  @linked_user_id
end

#nameObject (readonly)

Returns the value of attribute name.



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

def name
  @name
end

#other_namesObject (readonly)

Returns the value of attribute other_names.



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

def other_names
  @other_names
end

#updated_atObject (readonly)

Returns the value of attribute updated_at.



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

def updated_at
  @updated_at
end

Instance Method Details

#to_json(*_args) ⇒ Object



64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/e621_export_downloader/models/artist.rb', line 64

def to_json(*_args)
  {
    active_urls:    @active_urls,
    created_at:     @created_at,
    creator_id:     @creator_id,
    group_name:     @group_name,
    id:             @id,
    inactive_urls:  @inactive_urls,
    is_active:      @is_active,
    is_locked:      @is_locked,
    linked_user_id: @linked_user_id,
    name:           @name,
    other_names:    @other_names,
    updated_at:     @updated_at,
  }.to_json
end