Class: USMF

Inherits:
Object
  • Object
show all
Includes:
Logging
Defined in:
lib/model/USMF/USMF.rb

Overview

USMF standard message from Tawlk

See Also:

Author:

  • Daniel Machado Fernandez

Version:

  • 1.0

Constant Summary

Constants included from Logging

Logging::KermitPFC

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Logging

#logger, logger

Instance Attribute Details

#applicationObject

Returns the value of attribute application.



13
14
15
# File 'lib/model/USMF/USMF.rb', line 13

def application
  @application
end

#categoryObject

Returns the value of attribute category.



13
14
15
# File 'lib/model/USMF/USMF.rb', line 13

def category
  @category
end

#commentsObject

Returns the value of attribute comments.



13
14
15
# File 'lib/model/USMF/USMF.rb', line 13

def comments
  @comments
end

#dateObject

Returns the value of attribute date.



13
14
15
# File 'lib/model/USMF/USMF.rb', line 13

def date
  @date
end

#descriptionObject

Returns the value of attribute description.



13
14
15
# File 'lib/model/USMF/USMF.rb', line 13

def description
  @description
end

#dislikesObject

Returns the value of attribute dislikes.



13
14
15
# File 'lib/model/USMF/USMF.rb', line 13

def dislikes
  @dislikes
end

#durationObject

Returns the value of attribute duration.



13
14
15
# File 'lib/model/USMF/USMF.rb', line 13

def duration
  @duration
end

#favoritesObject

Returns the value of attribute favorites.



13
14
15
# File 'lib/model/USMF/USMF.rb', line 13

def favorites
  @favorites
end

#geoObject

Returns the value of attribute geo.



13
14
15
# File 'lib/model/USMF/USMF.rb', line 13

def geo
  @geo
end

#idObject

Returns the value of attribute id.



13
14
15
# File 'lib/model/USMF/USMF.rb', line 13

def id
  @id
end

#keywordsObject

Returns the value of attribute keywords.



13
14
15
# File 'lib/model/USMF/USMF.rb', line 13

def keywords
  @keywords
end

#likesObject

Returns the value of attribute likes.



13
14
15
# File 'lib/model/USMF/USMF.rb', line 13

def likes
  @likes
end

Returns the value of attribute links.



13
14
15
# File 'lib/model/USMF/USMF.rb', line 13

def links
  @links
end

#locationObject

Returns the value of attribute location.



13
14
15
# File 'lib/model/USMF/USMF.rb', line 13

def location
  @location
end

#max_ratingObject

Returns the value of attribute max_rating.



13
14
15
# File 'lib/model/USMF/USMF.rb', line 13

def max_rating
  @max_rating
end

#min_ratingObject

Returns the value of attribute min_rating.



13
14
15
# File 'lib/model/USMF/USMF.rb', line 13

def min_rating
  @min_rating
end

#ratesObject

Returns the value of attribute rates.



13
14
15
# File 'lib/model/USMF/USMF.rb', line 13

def rates
  @rates
end

#ratingObject

Returns the value of attribute rating.



13
14
15
# File 'lib/model/USMF/USMF.rb', line 13

def rating
  @rating
end

#serviceObject

Returns the value of attribute service.



13
14
15
# File 'lib/model/USMF/USMF.rb', line 13

def service
  @service
end

#sourceObject

Returns the value of attribute source.



13
14
15
# File 'lib/model/USMF/USMF.rb', line 13

def source
  @source
end

#textObject

Returns the value of attribute text.



13
14
15
# File 'lib/model/USMF/USMF.rb', line 13

def text
  @text
end

#to_usersObject

Returns the value of attribute to_users.



13
14
15
# File 'lib/model/USMF/USMF.rb', line 13

def to_users
  @to_users
end

#userObject

Returns the value of attribute user.



13
14
15
# File 'lib/model/USMF/USMF.rb', line 13

def user
  @user
end

Instance Method Details

#to_hashHash

Unify the fields into a hash

Returns:

  • (Hash)

    resultant hash



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/model/USMF/USMF.rb', line 29

def to_hash

	res = { 
          "service" => service, 
    		  "id" => id,
    			"geo" => geo,
    			"application" => application,
    			"location" => location,
    			"date" => date,
    			"source" => source,
    			"text" => text,
    			"description" => description,
    			"keywords" => keywords,
    			"category" => category,
    			"duration" => duration,
    			"likes" => likes,
    			"dislikes" => dislikes,
    			"favorites" => favorites,
    			"comments" => comments,
    			"rates" => rates,
    			"rating" => rating,
    			"min_rating" => min_rating,
    			"max_rating" => max_rating
		    }

    l = []
  
    unless :links == nil

      links.each do |link|

        l << link.to_hash

      end
  
      res["links"] = l
  
    end

    tu = []
  
    unless :to_users == nil

      to_users.each do |us|

        tu << us.to_hash

      end
  
      res["to_users"] = tu
  
    end

    begin
  
      if :user != nil
       res["user"] = user.to_hash
      end
  
    rescue
  
      #Sometimes a corrupt user was found
      res = nil
  
    end

	res

end

#to_sString

Unify the fields into a string

Returns:

  • (String)

    resultant string



19
20
21
22
23
24
# File 'lib/model/USMF/USMF.rb', line 19

def to_s

	res = "\nservice: " + service.to_s + "\nid: " + id.to_s + "\ngeo: " + geo.to_s + "\napplication: " + application.to_s + "\nlocation: " + location.to_s + "\ndate: " + date.to_s + "\nsource: " + source.to_s + "\ntext: " + text.to_s + "\ndescription: " + description.to_s + "\nkeywords: " + keywords.to_s + "\ncategory: " + category.to_s + "\nduration: " + duration.to_s + "\nlikes: " + likes.to_s + "\ndislikes: " + dislikes.to_s + "\nfavorites: " + favorites.to_s + "\ncomments: " + comments.to_s + "\nrates: " + rates.to_s + "\nrating: " + rating.to_s + "\nmin_rating: " + min_rating.to_s + "\nmax_rating: " + max_rating.to_s + "\n[USER]: " + user.to_s + "\n[TO_USERS]: " + to_users.to_s + "\n[LINKS]: " + links.to_s
	res

end