lib/ronin/formatting/extensions/html/integer.rb in ronin-support-0.5.0 vs lib/ronin/formatting/extensions/html/integer.rb in ronin-support-0.5.1
- old
+ new
@@ -112,14 +112,12 @@
# @since 0.2.0
#
# @api public
#
def js_escape
- if self > 0xff
- format_js
- else
- JS_ESCAPE_BYTES.fetch(self,chr)
+ if self > 0xff then format_js
+ else JS_ESCAPE_BYTES.fetch(self,chr)
end
end
#
# Formats the Integer as a JavaScript escaped String.
@@ -134,13 +132,11 @@
# @since 0.2.0
#
# @api public
#
def format_js
- if self > 0xff
- "\\u%.2X%.2X" % [(self & 0xff00) >> 8, (self & 0xff)]
- else
- "\\x%.2X" % self
+ if self > 0xff then "\\u%.4X" % self
+ else "\\x%.2X" % self
end
end
end