Class: Reading::Row::SourcesSubattribute

Inherits:
Object
  • Object
show all
Defined in:
lib/reading/attribute/variants/sources_subattribute.rb

Instance Method Summary collapse

Constructor Details

#initialize(bare_variant:, config:) ⇒ SourcesSubattribute

Returns a new instance of SourcesSubattribute.

Parameters:

  • bare_variant (String)

    the variant string before series / extra info.

  • config (Hash)


11
12
13
14
# File 'lib/reading/attribute/variants/sources_subattribute.rb', line 11

def initialize(bare_variant:, config:)
  @bare_variant = bare_variant
  @config = config
end

Instance Method Details

#parseObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/reading/attribute/variants/sources_subattribute.rb', line 16

def parse
  urls = sources_urls(bare_variant).map { |url|
    {
      name: url_name(url) || template.deep_fetch(:sources, 0, :name),
      url: url,
    }
  }

  names = sources_names(bare_variant).map { |name|
    {
      name: name,
      url: template.deep_fetch(:sources, 0, :url),
    }
  }

  (urls + names).presence
end