Module: MemberCardGenerator::InstanceMethods
- Included in:
- BlanksUsaIdc6
- Defined in:
- app/models/member_card_generator.rb
Instance Attribute Summary collapse
-
#download_url ⇒ Object
readonly
Returns the value of attribute download_url.
-
#members ⇒ Object
readonly
Returns the value of attribute members.
Instance Method Summary collapse
- #generate ⇒ Object
- #id ⇒ Object
- #initialize(members, template = 'blanks_usa_idc6') ⇒ Object
- #pdf_generator ⇒ Object
- #validate_members! ⇒ Object
Instance Attribute Details
#download_url ⇒ Object (readonly)
Returns the value of attribute download_url.
19 20 21 |
# File 'app/models/member_card_generator.rb', line 19 def download_url @download_url end |
#members ⇒ Object (readonly)
Returns the value of attribute members.
20 21 22 |
# File 'app/models/member_card_generator.rb', line 20 def members @members end |
Instance Method Details
#generate ⇒ Object
31 32 33 |
# File 'app/models/member_card_generator.rb', line 31 def generate @download_url = pdf_generator.generate end |
#id ⇒ Object
27 28 29 |
# File 'app/models/member_card_generator.rb', line 27 def id hash end |
#initialize(members, template = 'blanks_usa_idc6') ⇒ Object
22 23 24 25 |
# File 'app/models/member_card_generator.rb', line 22 def initialize(members, template='blanks_usa_idc6') @members = Array.wrap(members) validate_members! end |
#pdf_generator ⇒ Object
39 40 41 42 43 44 45 46 47 |
# File 'app/models/member_card_generator.rb', line 39 def pdf_generator @pdf_generator ||= begin PdfGeneration.new(self).tap do |p| p. = { :page_size => 'Letter' } end end end |
#validate_members! ⇒ Object
49 50 51 52 53 54 55 56 57 |
# File 'app/models/member_card_generator.rb', line 49 def validate_members! errors = [] members.each_with_index do |member,index| errors << " #{member.class} found at position #{index}" unless member.kind_of?(Member) end raise ArgumentError, "Only Member objects are supported for generating member cards:\n" + errors.join("\n") unless errors.empty? end |