Class: NOMS::Command::URInion::Data
- Inherits:
-
Object
- Object
- NOMS::Command::URInion::Data
- Defined in:
- lib/noms/command/urinion/data.rb
Instance Attribute Summary collapse
-
#character_set ⇒ Object
Returns the value of attribute character_set.
-
#data ⇒ Object
Returns the value of attribute data.
-
#data_encoding ⇒ Object
Returns the value of attribute data_encoding.
-
#fragment ⇒ Object
Returns the value of attribute fragment.
-
#host ⇒ Object
Returns the value of attribute host.
-
#mime_type ⇒ Object
Returns the value of attribute mime_type.
-
#password ⇒ Object
Returns the value of attribute password.
-
#path ⇒ Object
Returns the value of attribute path.
-
#port ⇒ Object
Returns the value of attribute port.
-
#query ⇒ Object
Returns the value of attribute query.
-
#raw_data ⇒ Object
Returns the value of attribute raw_data.
-
#scheme ⇒ Object
Returns the value of attribute scheme.
-
#user ⇒ Object
Returns the value of attribute user.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(urltext) ⇒ Data
constructor
A new instance of Data.
Constructor Details
#initialize(urltext) ⇒ Data
Returns a new instance of Data.
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/noms/command/urinion/data.rb', line 27 def initialize(urltext) @host = nil @port = nil @fragment = nil @user = nil @path = nil @password = nil @character_set = nil @scheme, rest = urltext.split(':', 2) raise NOMS::Command::Error.new "URL is not data: (scheme = #{@scheme})" unless @scheme == 'data' , @raw_data = rest.split(',', 2) fields = .split(';') if fields[-1] == 'base64' @data_encoding = fields.pop end unless fields[0].nil? or fields[0].empty? @mime_type = fields.shift end fields.each do |field| if m = /charset=(.*)/.match(field) @character_set = m[1] end end case @data_encoding when 'base64' @data = Base64.urlsafe_decode64 else @data = @raw_data end end |
Instance Attribute Details
#character_set ⇒ Object
Returns the value of attribute character_set.
19 20 21 |
# File 'lib/noms/command/urinion/data.rb', line 19 def character_set @character_set end |
#data ⇒ Object
Returns the value of attribute data.
19 20 21 |
# File 'lib/noms/command/urinion/data.rb', line 19 def data @data end |
#data_encoding ⇒ Object
Returns the value of attribute data_encoding.
19 20 21 |
# File 'lib/noms/command/urinion/data.rb', line 19 def data_encoding @data_encoding end |
#fragment ⇒ Object
Returns the value of attribute fragment.
19 20 21 |
# File 'lib/noms/command/urinion/data.rb', line 19 def fragment @fragment end |
#host ⇒ Object
Returns the value of attribute host.
19 20 21 |
# File 'lib/noms/command/urinion/data.rb', line 19 def host @host end |
#mime_type ⇒ Object
Returns the value of attribute mime_type.
19 20 21 |
# File 'lib/noms/command/urinion/data.rb', line 19 def mime_type @mime_type end |
#password ⇒ Object
Returns the value of attribute password.
19 20 21 |
# File 'lib/noms/command/urinion/data.rb', line 19 def password @password end |
#path ⇒ Object
Returns the value of attribute path.
19 20 21 |
# File 'lib/noms/command/urinion/data.rb', line 19 def path @path end |
#port ⇒ Object
Returns the value of attribute port.
19 20 21 |
# File 'lib/noms/command/urinion/data.rb', line 19 def port @port end |
#query ⇒ Object
Returns the value of attribute query.
19 20 21 |
# File 'lib/noms/command/urinion/data.rb', line 19 def query @query end |
#raw_data ⇒ Object
Returns the value of attribute raw_data.
19 20 21 |
# File 'lib/noms/command/urinion/data.rb', line 19 def raw_data @raw_data end |
#scheme ⇒ Object
Returns the value of attribute scheme.
19 20 21 |
# File 'lib/noms/command/urinion/data.rb', line 19 def scheme @scheme end |
#user ⇒ Object
Returns the value of attribute user.
19 20 21 |
# File 'lib/noms/command/urinion/data.rb', line 19 def user @user end |
Class Method Details
.parse(urltext) ⇒ Object
23 24 25 |
# File 'lib/noms/command/urinion/data.rb', line 23 def self.parse(urltext) self.new(urltext) end |