Class: INatGet::Data::Parser::Part::Copy Private

Inherits:
INatGet::Data::Parser::Part show all
Defined in:
lib/inat-get/data/parsers/defs/copy.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Direct Known Subclasses

Details, FromTaxon, JSON, Time

Instance Attribute Summary

Attributes inherited from INatGet::Data::Parser::Part

#parser

Instance Method Summary collapse

Constructor Details

#initialize(parser, *names, **aliases) ⇒ Copy

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Copy.



7
8
9
10
11
# File 'lib/inat-get/data/parsers/defs/copy.rb', line 7

def initialize parser, *names, **aliases
  super parser
  @names = names
  @aliases = aliases
end

Instance Method Details

#parse(source) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



13
14
15
16
17
18
19
20
21
22
# File 'lib/inat-get/data/parsers/defs/copy.rb', line 13

def parse source
  result = {}
  @names.each do |name|
    result[name] = source[name]
  end
  @aliases.each do |name, src_name|
    result[name] = source[src_name]
  end
  result
end