Sha256: f70243daa008898b5049148bbae5af71f6216e98c69b4838e66a44e0aea41196

Contents?: true

Size: 807 Bytes

Versions: 1

Compression:

Stored size: 807 Bytes

Contents

module FreebaseImporters
  class Book < Base
    map :id
    map :name
    map :characters, []

    add_to_mql :"type", "/book/book"
    # # This limits books somewhat to works significant enough to have been translated.
    # add_to_mql :"ns0:type", "/book/translated_work"

    map :"/book/book/editions", []

    add_to_mql :"/book/written_work/author", []
    add_method :authors, CommonAccessors.single(:"/book/written_work/author")

    add_to_mql :genre, []
    add_method :genres,  -> { data['genre'] }
    add_method :genre,   -> { genres.first   }

    add_to_mql :"/book/written_work/date_of_first_publication"
    add_method :date_of_first_publication, -> {
      pub = data["/book/written_work/date_of_first_publication"]
      pub ? Date.parse(pub) : nil rescue pub
    }
    images!
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
freebase-importers-0.0.6 lib/freebase_importers/book.rb