Class: String

Inherits:
Object show all
Defined in:
opal/browser/utils.rb,
opal/browser/css/unit.rb

Instance Method Summary collapse

Instance Method Details

#decode_uriString

Decode as URI.

Returns:

  • (String)

    the string decoded as URI



47
48
49
# File 'opal/browser/utils.rb', line 47

def decode_uri
  `decodeURI(self)`
end

#decode_uri_componentString

Decode as URI component.

Returns:

  • (String)

    the string decoded as URI component



40
41
42
# File 'opal/browser/utils.rb', line 40

def decode_uri_component
  `decodeURIComponent(self)`
end

#encode_uriString

Encode as URI.

Returns:

  • (String)

    the string encoded as URI



33
34
35
# File 'opal/browser/utils.rb', line 33

def encode_uri
  `encodeURI(self)`
end

#encode_uri_componentString

Encode as URI component.

Returns:

  • (String)

    the string encoded for usage as URI component



26
27
28
# File 'opal/browser/utils.rb', line 26

def encode_uri_component
  `encodeURIComponent(self)`
end

#to_uObject



169
170
171
172
173
174
175
176
177
178
179
180
181
# File 'opal/browser/css/unit.rb', line 169

def to_u
  if matches = self.match(/^([\d+.]+)(.+)?$/)
    value = matches[1].to_f

    if unit = matches[2]
      value.__send__(unit.downcase)
    else
      value
    end
  else
    0
  end
end