Class: CodeStock::Query

Inherits:
Object
  • Object
show all
Defined in:
lib/codestock/cdweb/lib/query.rb

Constant Summary collapse

OPTIONS =
[
 ['package',  'p'],
 ['filepath', 'fpath', 'f'],
 ['suffix',   's'],
]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(str) ⇒ Query

Returns a new instance of Query.



21
22
23
24
25
# File 'lib/codestock/cdweb/lib/query.rb', line 21

def initialize(str)
  @query_string = str
  init_hash
  parse
end

Instance Attribute Details

#query_stringObject (readonly)

Returns the value of attribute query_string.



13
14
15
# File 'lib/codestock/cdweb/lib/query.rb', line 13

def query_string
  @query_string
end

Instance Method Details

#empty?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/codestock/cdweb/lib/query.rb', line 31

def empty?
  keywords.size == 0 && packages.size == 0 && fpaths.size == 0 && suffixs.size == 0
end

#escape_htmlObject



27
28
29
# File 'lib/codestock/cdweb/lib/query.rb', line 27

def escape_html
  Rack::Utils::escape_html(@query_string)
end

#fpathsObject



43
44
45
# File 'lib/codestock/cdweb/lib/query.rb', line 43

def fpaths
  calc_param(1)
end

#keywordsObject



35
36
37
# File 'lib/codestock/cdweb/lib/query.rb', line 35

def keywords
  @hash['keywords']
end

#packagesObject



39
40
41
# File 'lib/codestock/cdweb/lib/query.rb', line 39

def packages
  calc_param(0)
end

#suffixsObject



47
48
49
# File 'lib/codestock/cdweb/lib/query.rb', line 47

def suffixs
  calc_param(2)
end