Class: UncleKryon::ArtistDataData

Inherits:
Object
  • Object
show all
Defined in:
lib/unclekryon/data/artist_data_data.rb

Constant Summary collapse

ID =
'ArtistData'
RELEASES_ID =
'Releases'
ALBUMS_ID =
'Albums'
AUMS_ID =
'Aums'
SCROLLS_ID =
'Scrolls'
VISIONS_ID =
'Visions'
PICS_ID =
'Pics'

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeArtistDataData

attr_accessor :aums attr_accessor :scrolls attr_accessor :visions attr_accessor :pics



42
43
44
45
46
47
48
49
50
51
# File 'lib/unclekryon/data/artist_data_data.rb', line 42

def initialize
  super()

  @releases = {}
  @albums = {}
  #@aums = {}
  #@scrolls = {}
  #@visions = {}
  #@pics = {}
end

Instance Attribute Details

#albumsObject

Returns the value of attribute albums.



36
37
38
# File 'lib/unclekryon/data/artist_data_data.rb', line 36

def albums
  @albums
end

#releasesObject

Returns the value of attribute releases.



35
36
37
# File 'lib/unclekryon/data/artist_data_data.rb', line 35

def releases
  @releases
end

Class Method Details

.load_file(filepath) ⇒ Object



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/unclekryon/data/artist_data_data.rb', line 53

def self.load_file(filepath)
  filedata = YAML.load_file(filepath) if File.exist?(filepath)
  filedata = {} if !filedata

  artist = ArtistDataData.new
  Util.hash_def(filedata,[ID],{})
  artist.releases = Util.hash_def(filedata,[ID,RELEASES_ID],artist.releases)
  artist.albums = Util.hash_def(filedata,[ID,ALBUMS_ID],artist.albums)
  #artist.aums = Util.hash_def(filedata,[ID,AUMS_ID],artist.aums)
  #artist.scrolls = Util.hash_def(filedata,[ID,SCROLLS_ID],artist.scrolls)
  #artist.visions = Util.hash_def(filedata,[ID,VISIONS_ID],artist.visions)
  #artist.pics = Util.hash_def(filedata,[ID,PICS_ID],artist.pics)

  return artist
end

Instance Method Details

#max_updated_onObject



86
87
88
89
90
91
92
93
94
95
96
# File 'lib/unclekryon/data/artist_data_data.rb', line 86

def max_updated_on
  max = nil
  max = Util.safe_max(max,BaseData.max_updated_on(@releases))
  max = Util.safe_max(max,BaseData.max_updated_on(@albums))
  #max = Util.safe_max(max,BaseData.max_updated_on(@aums))
  #max = Util.safe_max(max,BaseData.max_updated_on(@scrolls))
  #max = Util.safe_max(max,BaseData.max_updated_on(@visions))
  #max = Util.safe_max(max,BaseData.max_updated_on(@pics))

  return Util.format_datetime(max)
end

#save_to_file(filepath, **options) ⇒ Object



69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/unclekryon/data/artist_data_data.rb', line 69

def save_to_file(filepath,**options)
  raise "Empty filepath: #{filepath}" if filepath.nil? || (filepath = filepath.strip).empty?

  filedata = {ID => {}}
  filedata[ID][RELEASES_ID] = @releases
  filedata[ID][ALBUMS_ID] = @albums
  #filedata[ID][AUMS_ID] = @aums
  #filedata[ID][SCROLLS_ID] = @scrolls
  #filedata[ID][VISIONS_ID] = @visions
  #filedata[ID][PICS_ID] = @pics

  Util.mk_dirs_from_filepath(filepath)
  File.open(filepath,'w') do |f|
    YAML.dump(filedata,f)
  end
end

#to_mini_sObject



98
99
100
# File 'lib/unclekryon/data/artist_data_data.rb', line 98

def to_mini_s
  return to_s(true)
end

#to_s(mini = false) ⇒ Object



102
103
104
105
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
# File 'lib/unclekryon/data/artist_data_data.rb', line 102

def to_s(mini=false)
  s = ''

  s << "- Releases:\n"
  @releases.each do |k,v|
    s << '  - ' << v.to_s(mini).gsub("\n","\n    ") << "\n"
  end
  s << "- Albums:\n"
  @albums.each do |k,v|
    s << '  - ' << v.to_s(mini).gsub("\n","\n    ") << "\n"
  end

  #s << "- Aums:\n"
  #@aums.each() do |k,v|
  #  s << "  - #{v.to_s()}\n"
  #end
  #s << "- Scrolls:\n"
  #@scrolls.each() do |k,v|
  #  s << "  - #{v.to_s()}\n"
  #end
  #s << "- Visions:\n"
  #@visions.each() do |k,v|
  #  s << "  - #{v.to_s()}\n"
  #end
  #s << "- Pics:\n"
  #@pics.each() do |k,v|
  #  s << "  - #{v.to_s()}\n"
  #end

  return s
end