Class: Trackler::Metadata

Inherits:
Object
  • Object
show all
Defined in:
lib/trackler/metadata.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(metadata_file) ⇒ Metadata

Returns a new instance of Metadata.



11
12
13
14
15
16
17
# File 'lib/trackler/metadata.rb', line 11

def initialize()
  @file = 
  @attrs = YAML.load(@file.content) || {}
  %w(blurb source source_url).each do |attr|
    self.send("#{attr}=".to_sym, @attrs[attr].to_s.strip)
  end
end

Instance Attribute Details

#blurbObject

Returns the value of attribute blurb.



9
10
11
# File 'lib/trackler/metadata.rb', line 9

def blurb
  @blurb
end

#sourceObject

Returns the value of attribute source.



9
10
11
# File 'lib/trackler/metadata.rb', line 9

def source
  @source
end

#source_urlObject

Returns the value of attribute source_url.



9
10
11
# File 'lib/trackler/metadata.rb', line 9

def source_url
  @source_url
end

Class Method Details

.for(specification:, track:) ⇒ Object



5
6
7
# File 'lib/trackler/metadata.rb', line 5

def self.for(specification: , track: )
  new(GuaranteedFile.for(specification: specification, track: track, filename: 'metadata.yml'))
end

Instance Method Details

#exists?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/trackler/metadata.rb', line 23

def exists?
  !@attrs.empty?
end

#urlObject



19
20
21
# File 'lib/trackler/metadata.rb', line 19

def url
  @file.url
end