Skip to content

Commit

Permalink
Check additional 245 subfield(s). Might need more too... subfield a i…
Browse files Browse the repository at this point in the history
…sn't sufficient.
  • Loading branch information
fixlr committed Nov 18, 2009
1 parent b197276 commit c3ab53e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
11 changes: 10 additions & 1 deletion lib/wcapi/record.rb
Expand Up @@ -26,7 +26,16 @@ def link
end

def title
@title ||= xpath_get_text(xpath_first(@doc, "datafield[@tag='245']/subfield[@code='a']"))
unless @title
@title = []
xpath_all(@doc, "datafield[@tag='245']/subfield[@code='a']").each do |i|
@title << xpath_get_text(i)
end
xpath_all(@doc, "datafield[@tag='245']/subfield[@code='b']").each do |i|
@title << xpath_get_text(i)
end
end
return @title
end

def authors
Expand Down
2 changes: 1 addition & 1 deletion spec/wcapi/get_record_response_spec.rb
Expand Up @@ -37,7 +37,7 @@
end

it "should have a title" do
@record.title.should == 'Harry Potter and the Half-Blood Prince /'
@record.title.should == ['Harry Potter and the Half-Blood Prince /']
end

it "should have a link" do
Expand Down

0 comments on commit c3ab53e

Please sign in to comment.