Sha256: 2c629f7bffe3ab3f189c2743e0974583d734fc95c7db7d6307e689ed77499bea

Contents?: true

Size: 649 Bytes

Versions: 35

Compression:

Stored size: 649 Bytes

Contents

# frozen_string_literal: true

require "jr/cli/core_ext"

module Mihari
  module Feed
    class Parser
      attr_reader :data

      #
      # @param [Array<Hash>, Array<Array<String>>] data
      #
      def initialize(data)
        @data = data
      end

      #
      # Parse data by selector
      #
      # @param [String] selector
      #
      # @return [Array<String>]
      #
      def parse(selector)
        parsed = data.instance_eval(selector)

        raise FeedParseError unless parsed.is_a?(Array) || parsed.is_a?(Enumerator)
        raise FeedParseError unless parsed.all?(String)

        parsed.to_a
      end
    end
  end
end

Version data entries

35 entries across 35 versions & 1 rubygems

Version Path
mihari-4.6.1 lib/mihari/feed/parser.rb
mihari-4.6.0 lib/mihari/feed/parser.rb
mihari-4.5.3 lib/mihari/feed/parser.rb
mihari-4.5.2 lib/mihari/feed/parser.rb
mihari-4.5.1 lib/mihari/feed/parser.rb
mihari-4.5.0 lib/mihari/feed/parser.rb
mihari-4.4.1 lib/mihari/feed/parser.rb
mihari-4.4.0 lib/mihari/feed/parser.rb
mihari-4.3.0 lib/mihari/feed/parser.rb
mihari-4.2.0 lib/mihari/feed/parser.rb
mihari-4.1.2 lib/mihari/feed/parser.rb
mihari-4.1.1 lib/mihari/feed/parser.rb
mihari-4.1.0 lib/mihari/feed/parser.rb
mihari-4.0.0 lib/mihari/feed/parser.rb
mihari-3.12.0 lib/mihari/feed/parser.rb