class URI::Tag

Constants

AUTHORITY_PATTERN
COMPONENT
DATE_PATTERN
DNSCOMP_PATTERN
DNSNAME_PATTERN
PCHAR_PATTERN
SPECIFIC_PATTERN
SUB_DELIMS_PATTERN
TAG_REGEXP
UNRESERVED_PATTERN

Attributes

authority[R]
date[R]
fragment[R]
specific[R]

Public Class Methods

build(args) click to toggle source
Calls superclass method
# File lib/uri/tag.rb, line 25
def self.build(args)
  tmp = Util.make_components_hash(self, args)
  tmp[:opaque] = "%{authority},%{date}:%{specific}" % tmp

  return super(tmp)
end
new(*arg) click to toggle source
Calls superclass method
# File lib/uri/tag.rb, line 34
def initialize(*arg)
  super(*arg)

  self.opaque = @opaque
end

Public Instance Methods

authority=(value) click to toggle source
# File lib/uri/tag.rb, line 44
def authority=(value)
  check_authority(value)
  set_authority(value)
  value
end
date=(value) click to toggle source
# File lib/uri/tag.rb, line 50
def date=(value)
  check_date(value)
  set_date(value)
  value
end
date_to_time() click to toggle source

Description

Returns Time object which represents date part

Example:

require 'uri/tag'

uri = URI.parse('tag:example.org,2000:')
uri.date_to_time # => 2000-01-01 00:00:00 UTC
uri.date_to_time.class # => Time
# File lib/uri/tag.rb, line 90
def date_to_time
  Time.utc(*date.split('-'))
end
opaque=(value) click to toggle source
# File lib/uri/tag.rb, line 62
def opaque=(value)
  check_opaque(value)

  if TAG_REGEXP =~ value
    self.authority = $~['authority']
    self.date = $~['date']
    self.specific = $~['specific']
  else
    raise InvalidURIError, "bad URI(authority nor date not set?): #{self}" # raise InvalidURIError rather than InvalidComponentError, just because URI::Generic#check_opaque does so
  end

  set_opaque(value)
  value
end
specific=(value) click to toggle source
# File lib/uri/tag.rb, line 56
def specific=(value)
  check_specific(value)
  set_specific(value)
  value
end
tagging_entity() click to toggle source
# File lib/uri/tag.rb, line 40
def tagging_entity
  authority + ',' + date
end

Protected Instance Methods

set_authority(authority) click to toggle source
# File lib/uri/tag.rb, line 96
def set_authority(authority)
  @authority = authority
end
set_date(date) click to toggle source
# File lib/uri/tag.rb, line 100
def set_date(date)
  @date = date
end
set_specific(specific) click to toggle source
# File lib/uri/tag.rb, line 104
def set_specific(specific)
  @specific = specific
end

Private Instance Methods

check_authority(value) click to toggle source
# File lib/uri/tag.rb, line 110
def check_authority(value)
  if value !~ /\A(?:#{AUTHORITY_PATTERN})\z/o
    raise InvalidComponentError, "bad component(expected authority component: #{value})"
  end

  return true
end
check_date(value) click to toggle source
# File lib/uri/tag.rb, line 118
def check_date(value)
  if value !~ /\A(?:#{DATE_PATTERN}\z)/o
    raise InvalidComponentError, "bad component(expected date component: #{value})"
  end

  return true
end
check_specific(value) click to toggle source
# File lib/uri/tag.rb, line 126
def check_specific(value)
  if value !~ /\A#{SPECIFIC_PATTERN}\z/o
    raise InvalidComponentError, "bad component(expected specific component: #{value})"
  end

  return true
end