Class: ArXiv::ComposedQuery

Inherits:
Object
  • Object
show all
Includes:
QueryOperator
Defined in:
lib/ar_xiv/request.rb

Instance Method Summary collapse

Methods included from QueryOperator

#and, #andnot, #or

Constructor Details

#initialize(str, *args) ⇒ ComposedQuery

Returns a new instance of ComposedQuery.



50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/ar_xiv/request.rb', line 50

def initialize(str, *args)
  case str
  when String
    @op = str
    @requests = args
  when Query
    @op = ""
    @request = str
  else
    raise "Fail to make a Composed Request"
  end
end

Instance Method Details

#to_query_stringObject



63
64
65
66
67
68
69
# File 'lib/ar_xiv/request.rb', line 63

def to_query_string
  if @op.empty?
    @request.to_query_string
  else
    "%28#{@requests.map(&:to_query_string).join("%29+#{@op.upcase}+%28")}%29"
  end
end