Class: TextRazor::Topic

Inherits:
Object
  • Object
show all
Extended by:
Util
Defined in:
lib/textrazor/topic.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Util

standardize

Constructor Details

#initialize(params = {}) ⇒ Topic

Returns a new instance of Topic.



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

def initialize(params = {})
  params.each do |k, v|
    instance_variable_set(:"@#{k}", v) if v && self.respond_to?(:"#{k}")
  end
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



7
8
9
# File 'lib/textrazor/topic.rb', line 7

def id
  @id
end

#labelObject (readonly)

Returns the value of attribute label.



7
8
9
# File 'lib/textrazor/topic.rb', line 7

def label
  @label
end

#scoreObject (readonly)

Returns the value of attribute score.



7
8
9
# File 'lib/textrazor/topic.rb', line 7

def score
  @score
end

Returns the value of attribute wiki_link.



7
8
9
# File 'lib/textrazor/topic.rb', line 7

def wiki_link
  @wiki_link
end

Class Method Details

.create_from_hash(params) ⇒ Object



15
16
17
18
# File 'lib/textrazor/topic.rb', line 15

def self.create_from_hash(params)
  params = Hash[params.map {|k, v| [standardize(k), v] }]
  new(params)
end