Class: EhbrsRubyUtils::Music::Ous::Node

Inherits:
Object
  • Object
show all
Defined in:
lib/ehbrs_ruby_utils/music/ous/node.rb

Direct Known Subclasses

Album, Artist, Category

Constant Summary collapse

DEFAULT_LANGUAGE =
'unk'
LANGUAGE_FILE_BASENAME =
'.language'

Instance Method Summary collapse

Instance Method Details

#languageObject



21
22
23
# File 'lib/ehbrs_ruby_utils/music/ous/node.rb', line 21

def language
  self_language || parent_language || DEFAULT_LANGUAGE
end

#language_fileObject



25
26
27
# File 'lib/ehbrs_ruby_utils/music/ous/node.rb', line 25

def language_file
  path.join(LANGUAGE_FILE_BASENAME)
end

#nameObject



17
18
19
# File 'lib/ehbrs_ruby_utils/music/ous/node.rb', line 17

def name
  real_path.basename.to_s
end

#parent_languageObject



29
30
31
# File 'lib/ehbrs_ruby_utils/music/ous/node.rb', line 29

def parent_language
  parent_node.if_present(&:language)
end

#real_pathObject



33
34
35
# File 'lib/ehbrs_ruby_utils/music/ous/node.rb', line 33

def real_path
  path.readlink_r
end

#self_languageObject



37
38
39
# File 'lib/ehbrs_ruby_utils/music/ous/node.rb', line 37

def self_language
  language_file.if_exist('', &:read).strip.presence
end

#to_sObject



41
42
43
# File 'lib/ehbrs_ruby_utils/music/ous/node.rb', line 41

def to_s
  name
end