Class: Obp::Access::Parser

Inherits:
Object
  • Object
show all
Defined in:
lib/obp/access/parser.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(urn:, directory:) ⇒ Parser

Returns a new instance of Parser.



6
7
8
9
# File 'lib/obp/access/parser.rb', line 6

def initialize(urn:, directory:)
  @urn = urn
  @directory = directory
end

Instance Attribute Details

#directoryObject (readonly)

Returns the value of attribute directory.



4
5
6
# File 'lib/obp/access/parser.rb', line 4

def directory
  @directory
end

#urnObject (readonly)

Returns the value of attribute urn.



4
5
6
# File 'lib/obp/access/parser.rb', line 4

def urn
  @urn
end

Instance Method Details

#available_languagesObject



28
29
30
31
32
33
# File 'lib/obp/access/parser.rb', line 28

def available_languages
  state
    .select { |attr| !attr["caption"]&.empty? && attr["styles"]&.include?("toggle") }
    .filter_map { |attr| attr["caption"] }
    .uniq
end

#htmlObject



19
20
21
22
23
24
25
26
# File 'lib/obp/access/parser.rb', line 19

def html
  @html ||= begin
    content = state.filter_map { |attr| attr["htmlContent"] }.first
    raise "OBP content not found for URN #{urn}" unless content

    content
  end
end

#titleObject



15
16
17
# File 'lib/obp/access/parser.rb', line 15

def title
  tab_data["description"]
end

#to_xmlObject



11
12
13
# File 'lib/obp/access/parser.rb', line 11

def to_xml
  xml
end