Class: Athenaeum::Borrower
- Inherits:
-
Object
- Object
- Athenaeum::Borrower
- Defined in:
- lib/athenaeum/borrower.rb
Overview
Athenaeum::Borrower
Synopsis
Represents a person who has borrowed an item.
Accepts a <borrower> record (as an Hpricot::Elem) and creates an object that represents that data.
Authors
-
Ben Bleything <[email protected]>
Copyright
Copyright © 2007 LAIKA, Inc
Version
$Id: borrower.rb 287 2007-08-01 22:15:57Z bbleything $
Instance Attribute Summary collapse
-
#email ⇒ Object
readonly
Returns the value of attribute email.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
-
#initialize(info) ⇒ Borrower
constructor
takes an Hpricot::Elem representing a borrower.
-
#to_html ⇒ Object
return an HTML representation of this borrower.
Constructor Details
#initialize(info) ⇒ Borrower
takes an Hpricot::Elem representing a borrower.
31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/athenaeum/borrower.rb', line 31 def initialize( info ) raise "Must provide an Hpricot::Elem object" unless info.is_a? Hpricot::Elem @id = info[ :id ] if ab_record = fetch_ab_record( @id ) @name, @email = extract_data( ab_record ) else @name = @email = 'Unknown' end info.search( "/loan" ).each {|loan| Athenaeum::Loan.new( self, loan ) } end |
Instance Attribute Details
#email ⇒ Object (readonly)
Returns the value of attribute email.
28 29 30 |
# File 'lib/athenaeum/borrower.rb', line 28 def email @email end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
28 29 30 |
# File 'lib/athenaeum/borrower.rb', line 28 def id @id end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
28 29 30 |
# File 'lib/athenaeum/borrower.rb', line 28 def name @name end |
Instance Method Details
#to_html ⇒ Object
return an HTML representation of this borrower
47 48 49 50 51 52 53 54 55 |
# File 'lib/athenaeum/borrower.rb', line 47 def to_html inner = if email !~ /unknown email address/ "<a href='mailto:#{self.email}'>#{self.name}</a>" else self.name end return "<span class='borrower'>#{inner}</span>" end |