Class: Biller

Inherits:
Object
  • Object
show all
Defined in:
lib/invoices/models/biller.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#cityObject

Returns the value of attribute city.



2
3
4
# File 'lib/invoices/models/biller.rb', line 2

def city
  @city
end

#emailObject

Returns the value of attribute email.



2
3
4
# File 'lib/invoices/models/biller.rb', line 2

def email
  @email
end

#nameObject

Returns the value of attribute name.



2
3
4
# File 'lib/invoices/models/biller.rb', line 2

def name
  @name
end

#phoneObject

Returns the value of attribute phone.



2
3
4
# File 'lib/invoices/models/biller.rb', line 2

def phone
  @phone
end

#stateObject

Returns the value of attribute state.



2
3
4
# File 'lib/invoices/models/biller.rb', line 2

def state
  @state
end

#street1Object

Returns the value of attribute street1.



2
3
4
# File 'lib/invoices/models/biller.rb', line 2

def street1
  @street1
end

#street2Object

Returns the value of attribute street2.



2
3
4
# File 'lib/invoices/models/biller.rb', line 2

def street2
  @street2
end

#zipObject

Returns the value of attribute zip.



2
3
4
# File 'lib/invoices/models/biller.rb', line 2

def zip
  @zip
end

Instance Method Details

#default(*boolean) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/invoices/models/biller.rb', line 4

def default(*boolean)
  biller = choose_db(*boolean).execute("select * from billers").first
  @name = biller[0].to_s
  @street1 = biller[1].to_s
  @street2 = biller[2].to_s
  @city = biller[3].to_s
  @state = biller[4].to_s
  @zip = biller[5].to_s
  @phone = biller[6].to_s
  @email = biller[7].to_s
  return self
end

#save(*boolean) ⇒ Object



16
17
18
19
20
21
22
# File 'lib/invoices/models/biller.rb', line 16

def save(*boolean)
  # Should raise error unless all fields except for street2 are filled
  choose_db(*boolean).execute("INSERT INTO billers 
             (name, street1, street2, city, state, zip, phone, email) 
             VALUES (?, ?, ?, ?, ?, ?, ?, ?)", 
             [@name, @street1, @street2, @city, @state, @zip, @phone, @email])
end