123456789_123456789_123456789_123456789_123456789_

Class: RSS::BaseListener

Relationships & Source Files
Extension / Inclusion / Inheritance Descendants
Subclasses:
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
self, Utils
Inherits: Object
Defined in: lib/rss/parser.rb

Class Attribute Summary

Class Method Summary

Utils - Extended

element_initialize_arguments?

This method is used inside of several different objects to determine if special behavior is needed in the constructor.

get_file_and_line_from_caller

Returns an array of two elements: the filename where the calling method is located, and the line number where it is defined.

h,
html_escape

Takes a string s with some HTML in it, and escapes '&', '“', '<' and '>', by replacing them with the appropriate entities.

new_with_value_if_need

If value is an instance of class klass, return it, else create a new instance of klass with value value.

to_class_name

Given a name in a name_with_underscores or a name-with-dashes format, returns the CamelCase version of name.

Class Attribute Details

.raise_for_undefined_entity?Boolean (readonly)

[ GitHub ]

  
# File 'lib/rss/parser.rb', line 233

def raise_for_undefined_entity?
  true
end

Class Method Details

.available_tags(uri)

return the tag_names for setters associated with uri

[ GitHub ]

  
# File 'lib/rss/parser.rb', line 197

def available_tags(uri)
  (@@accessor_bases[uri] || {}).keys
end

.class_name(uri, tag_name)

retrieve class_name for the supplied uri and tag_name If it doesn't exist, capitalize the tag_name

[ GitHub ]

  
# File 'lib/rss/parser.rb', line 220

def class_name(uri, tag_name)
  name = (@@class_names[uri] || {})[tag_name]
  return name if name

  tag_name = tag_name.gsub(/[_\-]([a-z]?)/) {$1.upcase}
  tag_name[0, 1].upcase + tag_name[1..-1]
end

.def_get_text_element(uri, element_name, file, line) (private)

[ GitHub ]

  
# File 'lib/rss/parser.rb', line 244

def def_get_text_element(uri, element_name, file, line)
  register_uri(uri, element_name)
  method_name = "start_#{element_name}"
  unless private_method_defined?(method_name)
    define_method(method_name) do |name, prefix, attrs, ns|
      uri = _ns(ns, prefix)
      if self.class.uri_registered?(uri, element_name)
        start_get_text_element(name, prefix, ns, uri)
      else
        start_else_element(name, prefix, attrs, ns)
      end
    end
    private(method_name)
  end
end

.getter(uri, tag_name)

[ GitHub ]

  
# File 'lib/rss/parser.rb', line 192

def getter(uri, tag_name)
  (@@accessor_bases[uri] || {})[tag_name]
end

.install_accessor_base(uri, tag_name, accessor_base) (private)

set the accessor for the uri, tag_name pair

[ GitHub ]

  
# File 'lib/rss/parser.rb', line 239

def install_accessor_base(uri, tag_name, accessor_base)
  @@accessor_bases[uri] ||= {}
  @@accessor_bases[uri][tag_name] = accessor_base.chomp("=")
end

.install_class_name(uri, tag_name, class_name)

record class_name for the supplied uri and tag_name

[ GitHub ]

  
# File 'lib/rss/parser.rb', line 213

def install_class_name(uri, tag_name, class_name)
  @@class_names[uri] ||= {}
  @@class_names[uri][tag_name] = class_name
end

.install_get_text_element(uri, name, accessor_base)

[ GitHub ]

  
# File 'lib/rss/parser.rb', line 228

def install_get_text_element(uri, name, accessor_base)
  install_accessor_base(uri, name, accessor_base)
  def_get_text_element(uri, name, *get_file_and_line_from_caller(1))
end

.register_uri(uri, name)

register uri against this name.

[ GitHub ]

  
# File 'lib/rss/parser.rb', line 202

def register_uri(uri, name)
  @@registered_uris[name] ||= {}
  @@registered_uris[name][uri] = nil
end

.setter(uri, tag_name)

return the setter for the uri, tag_name pair, or nil.

[ GitHub ]

  
# File 'lib/rss/parser.rb', line 183

def setter(uri, tag_name)
  _getter = getter(uri, tag_name)
  if _getter
    "#{_getter}="
  else
    nil
  end
end

.uri_registered?(uri, name) ⇒ Boolean

test if this uri is registered against this name

[ GitHub ]

  
# File 'lib/rss/parser.rb', line 208

def uri_registered?(uri, name)
  @@registered_uris[name].has_key?(uri)
end