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.



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/e621_export_downloader/models/artist.rb', line 43

def initialize(record)
  @record = T.let(record, T::Hash[String, 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)
  @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)
  @urls           = T.let(T.must(record["urls"]).split("\n"), T::Array[String])
end

Instance Attribute Details

#created_atObject (readonly)

Returns the value of attribute created_at.



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

def created_at
  @created_at
end

#creator_idObject (readonly)

Returns the value of attribute creator_id.



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

def creator_id
  @creator_id
end

#group_nameObject (readonly)

Returns the value of attribute group_name.



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

def group_name
  @group_name
end

#idObject (readonly)

Returns the value of attribute id.



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

def id
  @id
end

#is_activeObject (readonly)

Returns the value of attribute is_active.



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

def is_active
  @is_active
end

#is_lockedObject (readonly)

Returns the value of attribute is_locked.



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

def is_locked
  @is_locked
end

#linked_user_idObject (readonly)

Returns the value of attribute linked_user_id.



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

def linked_user_id
  @linked_user_id
end

#nameObject (readonly)

Returns the value of attribute name.



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

def name
  @name
end

#other_namesObject (readonly)

Returns the value of attribute other_names.



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

def other_names
  @other_names
end

#updated_atObject (readonly)

Returns the value of attribute updated_at.



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

def updated_at
  @updated_at
end

#urlsObject (readonly)

Returns the value of attribute urls.



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

def urls
  @urls
end

Instance Method Details

#to_json(*_args) ⇒ Object



60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/e621_export_downloader/models/artist.rb', line 60

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