Class: E621::Search::Tags

Inherits:
Object
  • Object
show all
Defined in:
lib/rubyhexagon/search/tags.rb

Overview

Class to hold methods for Tag searches.

Since:

  • 1.0.0

Class Method Summary collapse

Class Method Details

.aliases(name, page = 1) ⇒ Array<Tag>

Retrieve information about aliased tags.

Parameters:

  • name (String)

    name pattern to search tags with

  • page (Integer) (defaults to: 1)

    page to retrieve

Returns:

  • (Array<Tag>)

    array of implicated tags for this tag

Raises:

  • ObjectNotFilledError if no name is present

Since:

  • 1.0.0



80
81
82
83
84
85
86
87
88
89
# File 'lib/rubyhexagon/search/tags.rb', line 80

def self.aliases(name, page = 1)
  params = { aliased_to: name, approved: true, page: page }
  tags = fetch_aliases(params)
  while block_given? && tags != []
    tags.each { |tag| yield tag unless tag.nil? }
    tags = fetch_aliases(params)
    params[:page] += 1
  end
  tags.compact
end

.implications(name, page = 1) ⇒ Array<Tag>

Retrieve information about implicated tags.

Parameters:

  • name (String)

    name pattern to search tags with

  • page (Integer) (defaults to: 1)

    page to retrieve

Returns:

  • (Array<Tag>)

    array of implicated tags for this tag

Raises:

  • ObjectNotFilledError if no name is present

Since:

  • 1.0.0



60
61
62
63
64
65
66
67
68
69
# File 'lib/rubyhexagon/search/tags.rb', line 60

def self.implications(name, page = 1)
  params = { implied_to: name, page: page }
  tags = fetch_implications(params)
  while block_given? && tags != []
    tags.each { |tag| yield tag unless tag.nil? }
    tags = fetch_implications(params)
    params[:page] += 1
  end
  tags.compact
end

.list(name, limit = 500, page = 1) ⇒ Array<Tag>

Retrieve a list of post data, which is filtered by arguments. This method accepts a block and returns only one page without one.

Parameters:

  • name (String)

    name pattern to search tags with

  • limit (Integer) (defaults to: 500)

    number of tags to return. This has a hard limit of 500

  • page (Integer) (defaults to: 1)

    page to retieve

Returns:

  • (Array<Tag>)

    array of tags

Since:

  • 1.0.0



39
40
41
42
43
44
45
46
47
48
49
# File 'lib/rubyhexagon/search/tags.rb', line 39

def self.list(name, limit = 500, page = 1)
  params = { name_pattern: name, order: :date, limit: limit,
             page: page }
  t = fetch_tags(params)
  while block_given? && t != []
    t.each { |tag| yield tag }
    params[:page] += 1
    t = fetch_tags(params)
  end
  t
end