app/models/tag.rb
# Return a machine tag hash for this tag, or an empty hash if this isn't a
# machine tag. The hash will always contain :namespace, :predicate and :value
# key-value pairs. It may also contain an :url if one is known.
#
# Machine tags describe references to remote resources. For example, a
# Calagator event imported from an Upcoming event may have a machine
# linking it back to the Upcoming event.
#
# Example:
#   # A tag named "upcoming:event=1234" will produce this machine tag:
#   tag.machine_tag == {
#     :namespace => "upcoming",
#     :predicate => "event",
#     :value     => "1234",
#     :url       => "http://upcoming.yahoo.com/event/1234",
Return a machine tag hash for this tag, or an empty hash if this isn't a
machine tag. The hash will always contain :namespace, :predicate and :value
key-value pairs. It may also contain an :url if one is known.

Machine tags describe references to remote resources. For example, a
Calagator event imported from an Upcoming event may have a machine
linking it back to the Upcoming event.


Return a machine tag hash for this tag or an empty hash if this isn ' t a machine tag . The hash will always contain : namespace : predicate and : value key - value pairs . It may also contain an : url if one is known . Machine tags describe references to remote resources . For example a Calagator event imported from an Upcoming event may have a machine linking it back to the Upcoming event .
def machine_tag
    if components = self.name.match(MACHINE_TAG_PATTERN)
      namespace, predicate, value = components.captures
      result = {
        :namespace => namespace,
        :predicate => predicate,
        :value     => value,
      }
      if url_template = MACHINE_TAG_URLS[namespace].try(:[], predicate)
        result[:url] = sprintf(url_template, value)
      end
      return result
    else
      return {}
    end
  end
def machine_tag if components = self . name . match ( MACHINE_TAG_PATTERN ) namespace , predicate , value = components . captures result = { :namespace => namespace , :predicate => predicate , :value => value , } if url_template = MACHINE_TAG_URLS [ namespace ] . try ( :[] , predicate ) result [ :url ] = sprintf ( url_template , value ) end return result else return { } end end
Return a machine tag hash for this tag, or an empty hash if this isn't a
machine tag.
Return a machine tag hash for this tag or an empty hash if this isn ' t a machine tag .