Sha256: ccf9384994483df8fbeb5d9a2b130ff50e8da1ab13a499f1e163633a148c7a34

Contents?: true

Size: 1.13 KB

Versions: 23

Compression:

Stored size: 1.13 KB

Contents

# frozen_string_literal: true

module RelatonItu
  # Hit.
  class Hit
    # @return [Isobib::HitCollection]
    attr_reader :hit_collection

    # @return [Array<Hash>]
    attr_reader :hit

    # @param hit [Hash]
    # @param hit_collection [Isobib:HitCollection]
    def initialize(hit, hit_collection = nil)
      @hit            = hit
      @hit_collection = hit_collection
    end

    # Parse page.
    # @return [Isobib::IsoBibliographicItem]
    def fetch
      @fetch ||= Scrapper.parse_page @hit
    end

    # @return [String]
    def to_s
      inspect
    end

    # @return [String]
    def inspect
      "<#{self.class}:#{format('%#.14x', object_id << 1)} "\
      "@text=\"#{@hit_collection&.text}\" "\
      "@fetched=\"#{!@fetch.nil?}\" "\
      "@fullIdentifier=\"#{@fetch&.shortref(nil)}\" "\
      "@title=\"#{@hit[:code]}\">"
    end

    # @return [String]
    def to_xml(opts = {})
      #if builder
        #fetch.to_xml builder, opts
      #else
        builder = Nokogiri::XML::Builder.new(encoding: 'UTF-8') do |xml|
          fetch.to_xml xml, opts
        end
        builder.doc.root.to_xml
      #end
    end
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
relaton-itu-0.7.0 lib/relaton_itu/hit.rb
relaton-itu-0.6.0 lib/relaton_itu/hit.rb
relaton-itu-0.5.1 lib/relaton_itu/hit.rb
relaton-itu-0.5.0 lib/relaton_itu/hit.rb
relaton-itu-0.4.1 lib/relaton_itu/hit.rb
relaton-itu-0.4.0 lib/relaton_itu/hit.rb
relaton-itu-0.3.11 lib/relaton_itu/hit.rb
relaton-itu-0.3.10 lib/relaton_itu/hit.rb
relaton-itu-0.3.9 lib/relaton_itu/hit.rb
relaton-itu-0.3.8 lib/relaton_itu/hit.rb
relaton-itu-0.3.7 lib/relaton_itu/hit.rb
relaton-itu-0.3.6 lib/relaton_itu/hit.rb
relaton-itu-0.3.5 lib/relaton_itu/hit.rb
relaton-itu-0.3.4 lib/relaton_itu/hit.rb
relaton-itu-0.3.3 lib/relaton_itu/hit.rb
relaton-itu-0.3.2 lib/relaton_itu/hit.rb
relaton-itu-0.3.1 lib/relaton_itu/hit.rb
relaton-itu-0.3.0 lib/relaton_itu/hit.rb
relaton-itu-0.2.3 lib/relaton_itu/hit.rb
relaton-itu-0.2.2 lib/relaton_itu/hit.rb