Sha256: 4fb344285404608ece36206afad5ab4d354fed2a8c46891dfb985b340c3ed4a9

Contents?: true

Size: 772 Bytes

Versions: 23

Compression:

Stored size: 772 Bytes

Contents

module RelatonBib
  class Place
    # @return [String]
    attr_reader :name

    # @return [String, NilClass]
    attr_reader :uri, :region

    # @param name [String]
    # @param uri [String, NilClass]
    # @param region [String, NilClass]
    def initialize(name:, uri: nil, region: nil)
      @name   = name
      @uri    = uri
      @region = region
    end

    # @param builder [Nologiri::XML::Builder]
    def to_xml(builder)
      xml = builder.place name
      xml[:uri] = uri if uri
      xml[:region] = region if region
    end

    # @return [Hash]
    def to_hash
      if uri || region
        hash = { name: name }
        hash["uri"] = uri if uri
        hash["region"] = region if region
        hash
      else
        name
      end
    end
  end
end

Version data entries

23 entries across 23 versions & 2 rubygems

Version Path
relaton-bib-0.5.2 lib/relaton_bib/place.rb
relaton-bib-0.5.1 lib/relaton_bib/place.rb
relaton-bib-0.5.0 lib/relaton_bib/place.rb