Class: Classifoclc::Work

Inherits:
Object
  • Object
show all
Defined in:
lib/classifoclc/work.rb

Overview

An abstract work. A work is not a physical book, but the conceptual work of which all the physical books are manifestions

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(node) ⇒ Work

Returns a new instance of Work.



6
7
8
9
10
11
12
# File 'lib/classifoclc/work.rb', line 6

def initialize(node)
  @node = node
  @work = node.css('work').first
  @authors = node.css('author').
               map{|a| Classifoclc::Author.new(a.text, a['lc'], a['viaf'])}
  @recommendations = load_recommendations(node)
end

Instance Attribute Details

#authorsObject (readonly)

Returns the value of attribute authors.



5
6
7
# File 'lib/classifoclc/work.rb', line 5

def authors
  @authors
end

Instance Method Details

#edition_countInteger

Get the number of editions the work has

Returns:

  • (Integer)


40
41
42
# File 'lib/classifoclc/work.rb', line 40

def edition_count
  @work['editions'].to_i
end

#editionsEnumerator<Classifoclc::Edition>

Get the editions of this work

Returns:



58
59
60
61
62
63
64
65
66
# File 'lib/classifoclc/work.rb', line 58

def editions
  Enumerator.new do |e|
    pages.each do |pg|
      pg.each do |edition|
        e << edition
      end
    end
  end
end

#eholdingsInteger

Get the number of libraries that hold a digital copy of this work

Returns:

  • (Integer)


52
53
54
# File 'lib/classifoclc/work.rb', line 52

def eholdings
  @work['eholdings'].to_i
end

#formatString

Get the format

Returns:

  • (String)


28
29
30
# File 'lib/classifoclc/work.rb', line 28

def format
  @work['format']
end

#holdingsInteger

Get the number of libraries that hold a copy of this work

Returns:

  • (Integer)


46
47
48
# File 'lib/classifoclc/work.rb', line 46

def holdings
  @work['holdings'].to_i
end

#itemtypeString

Get the type of item

Returns:

  • (String)


34
35
36
# File 'lib/classifoclc/work.rb', line 34

def itemtype
  @work['itemtype']
end

#owiString

Get the work ID

Returns:

  • (String)


16
17
18
# File 'lib/classifoclc/work.rb', line 16

def owi
  @work['owi']
end

#recommendationsArray<Classifoclc::Recommendations>

Get the recommended classifications for this work

Returns:



70
71
72
# File 'lib/classifoclc/work.rb', line 70

def recommendations
  @recommendations
end

#titleString

Get the title

Returns:

  • (String)


22
23
24
# File 'lib/classifoclc/work.rb', line 22

def title
  @work['title']
end