Class: Cowordinate::Word

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Word

Returns a new instance of Word.



24
25
26
27
28
# File 'lib/cowordinate/word.rb', line 24

def initialize(options)
  self.name = options["name"]
  self.parts = options["parts"]
  self.updated_at = options["updated_at"]
end

Instance Attribute Details

#nameObject

Returns the value of attribute name.



14
15
16
# File 'lib/cowordinate/word.rb', line 14

def name
  @name
end

#partsObject

Returns the value of attribute parts.



14
15
16
# File 'lib/cowordinate/word.rb', line 14

def parts
  @parts
end

#updated_atObject

Returns the value of attribute updated_at.



14
15
16
# File 'lib/cowordinate/word.rb', line 14

def updated_at
  @updated_at
end

Class Method Details

.search(name) ⇒ Object



16
17
18
19
20
21
22
# File 'lib/cowordinate/word.rb', line 16

def self.search(name)
	raw_json = HTTParty.get("http://cowordinate.com/words/#{name}.json")
	attrs = JSON.parse(raw_json.body)
	Cowordinate::Word.new(attrs["word"])
rescue
  nil
end