Class: GoogleFish

Inherits:
Object
  • Object
show all
Defined in:
lib/google_fish.rb

Defined Under Namespace

Classes: Request

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key) ⇒ GoogleFish

Returns a new instance of GoogleFish.



4
5
6
7
# File 'lib/google_fish.rb', line 4

def initialize(key)
  @key = key
  @format = :text
end

Instance Attribute Details

#formatObject

Returns the value of attribute format.



2
3
4
# File 'lib/google_fish.rb', line 2

def format
  @format
end

#keyObject

Returns the value of attribute key.



2
3
4
# File 'lib/google_fish.rb', line 2

def key
  @key
end

#qObject

Returns the value of attribute q.



2
3
4
# File 'lib/google_fish.rb', line 2

def q
  @q
end

#sourceObject

Returns the value of attribute source.



2
3
4
# File 'lib/google_fish.rb', line 2

def source
  @source
end

#targetObject

Returns the value of attribute target.



2
3
4
# File 'lib/google_fish.rb', line 2

def target
  @target
end

#translated_textObject

Returns the value of attribute translated_text.



2
3
4
# File 'lib/google_fish.rb', line 2

def translated_text
  @translated_text
end

Instance Method Details

#translate(source, target, q, options = {}) ⇒ Object



9
10
11
12
13
# File 'lib/google_fish.rb', line 9

def translate(source, target, q, options={})
  @format = :html if options[:html]
  @source, @target, @q = source, target, q
  @translated_text = request_translation
end