Class: Fleakr::Objects::Tag

Inherits:
Object
  • Object
show all
Includes:
Support::Object
Defined in:
lib/fleakr/objects/tag.rb

Overview

Tag

This class represents a tag that can be associated with a photo or an individual user.

Attributes

id

The unique identifier for this tag

raw

The raw, user-entered value for this tag

value

The formatted value for this tag. Also available through to_s

Instance Method Summary collapse

Methods included from Support::Object

included

Instance Method Details

#authorObject

The first user who created this tag. See Fleakr::Objects::User for more information



28
29
30
# File 'lib/fleakr/objects/tag.rb', line 28

def author
  @author ||= User.find_by_id(author_id) unless author_id.nil?
end

#machine?Boolean

Is this a machine tag?

Returns:

  • (Boolean)


43
44
45
# File 'lib/fleakr/objects/tag.rb', line 43

def machine?
  machine_flag != '0'
end

A list of related tags. Each of the objects in the collection is an instance of Tag



34
35
36
37
38
39
# File 'lib/fleakr/objects/tag.rb', line 34

def related
  @related ||= begin
    response = Fleakr::Api::MethodRequest.with_response!('tags.getRelated', :tag => value)
    (response.body/'rsp/tags/tag').map {|e| Tag.new(e) }
  end
end

#to_sObject

The formatted value of the tag. Also available as value



49
50
51
# File 'lib/fleakr/objects/tag.rb', line 49

def to_s
  value
end