Sha256: a9eb5c8cf73281440a64a5b31b4ff82f20c5dca31ede758432cd4f89cbd76df0

Contents?: true

Size: 1.03 KB

Versions: 53

Compression:

Stored size: 1.03 KB

Contents

module Eco::Data::Locations::NodeBase
  module Builder
    include Eco::Data::Locations::NodeBase::Parsing
    include Eco::Data::Locations::NodeBase::Serial
    include Eco::Data::Locations::NodeBase::CsvConvert
    include Eco::Data::Locations::NodeBase::Treeify

    # @param data [CSV::Table, NodeBase, Array<NodeBase>]
    # @return [NodeBase::Class] the Node class we can use.
    def node_class(data)
      case data
      when ::CSV::Table
        return Eco::Data::Locations::NodePlain if Eco::Data::Locations::NodePlain.csv_matches_format?(csv)
        return Eco::Data::Locations::NodeLevel if Eco::Data::Locations::NodeLevel.csv_matches_format?(csv)
      when Array
        return nil unless sample = data.first
        node_class(sample)
      when Eco::Data::Locations::NodeBase
        return nil unless data.class < Eco::Data::Locations::NodeBase
        data.class
      else
        raise ArgumentError, "Expecting CSV::Table. Given: #{csv.class}" unless csv.is_a?(::CSV::Table)
      end
    end
  end
end

Version data entries

53 entries across 53 versions & 1 rubygems

Version Path
eco-helpers-3.0.21 lib/eco/data/locations/node_base/builder.rb
eco-helpers-3.0.20 lib/eco/data/locations/node_base/builder.rb
eco-helpers-3.0.19 lib/eco/data/locations/node_base/builder.rb
eco-helpers-3.0.18 lib/eco/data/locations/node_base/builder.rb
eco-helpers-3.0.17 lib/eco/data/locations/node_base/builder.rb
eco-helpers-3.0.16 lib/eco/data/locations/node_base/builder.rb
eco-helpers-3.0.15 lib/eco/data/locations/node_base/builder.rb
eco-helpers-3.0.14 lib/eco/data/locations/node_base/builder.rb
eco-helpers-3.0.13 lib/eco/data/locations/node_base/builder.rb
eco-helpers-3.0.12 lib/eco/data/locations/node_base/builder.rb
eco-helpers-3.0.11 lib/eco/data/locations/node_base/builder.rb
eco-helpers-3.0.10 lib/eco/data/locations/node_base/builder.rb
eco-helpers-3.0.9 lib/eco/data/locations/node_base/builder.rb
eco-helpers-3.0.8 lib/eco/data/locations/node_base/builder.rb
eco-helpers-3.0.7 lib/eco/data/locations/node_base/builder.rb
eco-helpers-3.0.6 lib/eco/data/locations/node_base/builder.rb
eco-helpers-3.0.5 lib/eco/data/locations/node_base/builder.rb
eco-helpers-3.0.4 lib/eco/data/locations/node_base/builder.rb
eco-helpers-3.0.3 lib/eco/data/locations/node_base/builder.rb
eco-helpers-3.0.2 lib/eco/data/locations/node_base/builder.rb