Class: Docs::Knockout::EntriesFilter

Inherits:
EntriesFilter show all
Defined in:
lib/docs/filters/knockout/entries.rb

Constant Summary collapse

NAME_BY_SLUG =
{
'custom-bindings'                                 => 'Custom bindings',
'custom-bindings-controlling-descendant-bindings' => 'Descendant bindings',
'custom-bindings-for-virtual-elements'            => 'Virtual elements',
'binding-preprocessing'                           => 'Binding preprocessing',
'json-data'                                       => 'JSON data',
'extenders'                                       => 'Extending observables',
'unobtrusive-event-handling'                      => 'Event handling',
'fn'                                              => 'Custom functions',
'ratelimit-observable'                            => 'rateLimit extender' }

Constants inherited from Filter

Filter::SCHEME_RGX

Instance Method Summary collapse

Methods inherited from EntriesFilter

#additional_entries, #build_entries, #build_entry, #call, #default_entry, #entries, #include_default_entry?, #name, #path, #type

Methods inherited from Filter

#absolute_url_string?, #at_css, #at_xpath, #base_url, #css, #current_url, #fragment_url_string?, #initial_page?, #parse_html, #relative_url_string?, #root_page?, #root_path, #root_url, #slug, #subpath, #subpath_to, #xpath

Instance Method Details

#get_nameObject


15
16
17
18
19
20
21
22
# File 'lib/docs/filters/knockout/entries.rb', line 15

def get_name
  return NAME_BY_SLUG[slug] if NAME_BY_SLUG.has_key?(slug)
  name = at_css('h1').content.strip
  name.remove! 'The '
  name.sub! %r{"(.+?)"}, '\1'
  name.gsub!(/ [A-Z]/) { |str| str.downcase! }
  name
end

#get_typeObject


24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/docs/filters/knockout/entries.rb', line 24

def get_type
  if name =~ /observable/i || slug =~ /extender/
    'Observables'
  elsif slug.include?('binding') && !name.end_with?('binding')
    'Binding'
  elsif slug.include? 'binding'
    'Bindings'
  elsif slug.include? 'plugin'
    'Plugins'
  else
    'Miscellaneous'
  end
end