Class: TypeFront
- Inherits:
-
Object
show all
- Defined in:
- lib/typefront.rb
Constant Summary
collapse
- VERSION =
'0.2.1'
- DOMAIN =
'http://typefront.com'
Instance Method Summary
collapse
Constructor Details
#initialize(email, password) ⇒ TypeFront
Returns a new instance of TypeFront.
9
10
11
12
13
14
15
16
17
18
|
# File 'lib/typefront.rb', line 9
def initialize(email, password)
@default_options = {
:user => email,
:password => password,
:content_type => :json,
:accept => :json,
:headers => { :user_agent => "typefront-ruby/#{VERSION}" }
}
@resource = RestClient::Resource.new("#{DOMAIN}", @default_options)
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args) ⇒ Object
54
55
56
57
58
59
60
|
# File 'lib/typefront.rb', line 54
def method_missing(name, *args)
if [:get, :post, :put, :delete].include?(name)
send(:send_request, name, args[0], args[1] || {})
else
super
end
end
|
Instance Method Details
36
37
38
|
# File 'lib/typefront.rb', line 36
def activate_format(font_id, format_id)
put("/fonts/#{font_id}/formats/#{format_id}.json", :font_format => { :active => true })
end
|
#add_domain(font_id, domain) ⇒ Object
44
45
46
|
# File 'lib/typefront.rb', line 44
def add_domain(font_id, domain)
post("/fonts/#{font_id}/domains.json", :domain => { :domain => domain })
end
|
40
41
42
|
# File 'lib/typefront.rb', line 40
def disable_format(font_id, format_id)
put("/fonts/#{font_id}/formats/#{format_id}.json", :font_format => { :active => false })
end
|
#font_details(font_id) ⇒ Object
24
25
26
|
# File 'lib/typefront.rb', line 24
def font_details(font_id)
get("/fonts/#{font_id}.json")
end
|
#fonts ⇒ Object
20
21
22
|
# File 'lib/typefront.rb', line 20
def fonts
get('/fonts.json')
end
|
#remove_domain(font_id, domain_id) ⇒ Object
48
49
50
|
# File 'lib/typefront.rb', line 48
def remove_domain(font_id, domain_id)
delete("/fonts/#{font_id}/domains/#{domain_id}.json")
end
|
#remove_font(font_id) ⇒ Object
32
33
34
|
# File 'lib/typefront.rb', line 32
def remove_font(font_id)
delete("/fonts/#{font_id}.json")
end
|
#upload_font(file) ⇒ Object
28
29
30
|
# File 'lib/typefront.rb', line 28
def upload_font(file)
post('/fonts.json', :font => { :original => file })
end
|