Class: Client

Inherits:
Object
  • Object
show all
Defined in:
lib/invoices/models/client.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/client.rb', line 2

def city
  @city
end

#emailObject

Returns the value of attribute email.



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

def email
  @email
end

#idObject

Returns the value of attribute id.



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

def id
  @id
end

#nameObject

Returns the value of attribute name.



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

def name
  @name
end

#phoneObject

Returns the value of attribute phone.



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

def phone
  @phone
end

#rateObject

Returns the value of attribute rate.



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

def rate
  @rate
end

#stateObject

Returns the value of attribute state.



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

def state
  @state
end

#street1Object

Returns the value of attribute street1.



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

def street1
  @street1
end

#street2Object

Returns the value of attribute street2.



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

def street2
  @street2
end

#zipObject

Returns the value of attribute zip.



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

def zip
  @zip
end

Instance Method Details

#find_by_name(name, *boolean) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/invoices/models/client.rb', line 4

def find_by_name(name, *boolean)
  client = choose_db(*boolean).execute("select * from clients 
                      where name = '#{name}'").first
  @id = choose_db(*boolean).execute("select rowid from clients 
                   where name = '#{name}'").first
  @name = client[0].to_s
  @street1 = client[1].to_s
  @street2 = client[2].to_s
  @city = client[3].to_s
  @state = client[4].to_s
  @zip = client[5].to_s
  @phone = client[6].to_s
  @email = client[7].to_s
  @rate = client[8]
  return self
end

#save(*boolean) ⇒ Object



20
21
22
23
24
25
26
# File 'lib/invoices/models/client.rb', line 20

def save(*boolean)
  choose_db(*boolean).execute("INSERT INTO clients 
             (name, street1, street2, city, state, 
             zip, phone, email, rate) 
             VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)", 
             [@name, @street1, @street2, @city, @state, @zip, @phone, @email, @rate])
end