Class: Iqdb::Client::Parser::Alt

Inherits:
Object
  • Object
show all
Defined in:
lib/iqdb/client/parser/alt.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(str) ⇒ Alt

Returns a new instance of Alt.



7
8
9
# File 'lib/iqdb/client/parser/alt.rb', line 7

def initialize(str)
  @str = str
end

Instance Attribute Details

#strObject (readonly)

Returns the value of attribute str.



5
6
7
# File 'lib/iqdb/client/parser/alt.rb', line 5

def str
  @str
end

Instance Method Details

#ratingObject



15
16
17
# File 'lib/iqdb/client/parser/alt.rb', line 15

def rating
  @rating ||= str.scan(/Rating:\s(\w)\s/).then { |m| m.empty? ? '' : m[0][0] }
end

#tagsObject



11
12
13
# File 'lib/iqdb/client/parser/alt.rb', line 11

def tags
  @tags ||= str.scan(/Tags:(.+)$/).then { |m| m.empty? ? [] : m[0][0].split(' ') }
end