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-5.2.2 lib/mihari/feed/parser.rb
mihari-5.2.1 lib/mihari/feed/parser.rb
mihari-5.2.0 lib/mihari/feed/parser.rb
mihari-5.1.4 lib/mihari/feed/parser.rb
mihari-5.1.3 lib/mihari/feed/parser.rb
mihari-5.1.2 lib/mihari/feed/parser.rb
mihari-5.1.1 lib/mihari/feed/parser.rb
mihari-5.1.0 lib/mihari/feed/parser.rb
mihari-5.0.1 lib/mihari/feed/parser.rb
mihari-5.0.0 lib/mihari/feed/parser.rb
mihari-4.12.0 lib/mihari/feed/parser.rb
mihari-4.11.0 lib/mihari/feed/parser.rb
mihari-4.10.0 lib/mihari/feed/parser.rb
mihari-4.9.0 lib/mihari/feed/parser.rb
mihari-4.8.0 lib/mihari/feed/parser.rb
mihari-4.7.4 lib/mihari/feed/parser.rb
mihari-4.7.3 lib/mihari/feed/parser.rb
mihari-4.7.2 lib/mihari/feed/parser.rb
mihari-4.7.1 lib/mihari/feed/parser.rb
mihari-4.7.0 lib/mihari/feed/parser.rb