repo
stringlengths
5
58
path
stringlengths
9
168
func_name
stringlengths
9
130
original_string
stringlengths
66
10.5k
language
stringclasses
1 value
code
stringlengths
66
10.5k
code_tokens
list
docstring
stringlengths
8
16k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
94
266
partition
stringclasses
1 value
rmagick/rmagick
lib/rvg/rvg.rb
Magick.RVG.background_image=
def background_image=(bg_image) warn 'background_image= has no effect in nested RVG objects' if @nested raise ArgumentError, "background image must be an Image (got #{bg_image.class})" if bg_image && !bg_image.is_a?(Magick::Image) @background_image = bg_image end
ruby
def background_image=(bg_image) warn 'background_image= has no effect in nested RVG objects' if @nested raise ArgumentError, "background image must be an Image (got #{bg_image.class})" if bg_image && !bg_image.is_a?(Magick::Image) @background_image = bg_image end
[ "def", "background_image", "=", "(", "bg_image", ")", "warn", "'background_image= has no effect in nested RVG objects'", "if", "@nested", "raise", "ArgumentError", ",", "\"background image must be an Image (got #{bg_image.class})\"", "if", "bg_image", "&&", "!", "bg_image", "."...
Sets an image to use as the canvas background. See background_position= for layout options.
[ "Sets", "an", "image", "to", "use", "as", "the", "canvas", "background", ".", "See", "background_position", "=", "for", "layout", "options", "." ]
ef6688ed9d76bf123c2ea1a483eff8635051adb7
https://github.com/rmagick/rmagick/blob/ef6688ed9d76bf123c2ea1a483eff8635051adb7/lib/rvg/rvg.rb#L140-L145
train
rmagick/rmagick
lib/rvg/rvg.rb
Magick.RVG.add_outermost_primitives
def add_outermost_primitives(gc) #:nodoc: add_transform_primitives(gc) gc.push add_viewbox_primitives(@width, @height, gc) add_style_primitives(gc) @content.each { |element| element.add_primitives(gc) } gc.pop self end
ruby
def add_outermost_primitives(gc) #:nodoc: add_transform_primitives(gc) gc.push add_viewbox_primitives(@width, @height, gc) add_style_primitives(gc) @content.each { |element| element.add_primitives(gc) } gc.pop self end
[ "def", "add_outermost_primitives", "(", "gc", ")", "#:nodoc:", "add_transform_primitives", "(", "gc", ")", "gc", ".", "push", "add_viewbox_primitives", "(", "@width", ",", "@height", ",", "gc", ")", "add_style_primitives", "(", "gc", ")", "@content", ".", "each"...
Primitives for the outermost RVG object
[ "Primitives", "for", "the", "outermost", "RVG", "object" ]
ef6688ed9d76bf123c2ea1a483eff8635051adb7
https://github.com/rmagick/rmagick/blob/ef6688ed9d76bf123c2ea1a483eff8635051adb7/lib/rvg/rvg.rb#L260-L268
train
rmagick/rmagick
lib/rvg/rvg.rb
Magick.RVG.add_primitives
def add_primitives(gc) #:nodoc: raise ArgumentError, 'RVG width or height undefined' if @width.nil? || @height.nil? return self if @width.zero? || @height.zero? gc.push add_outermost_primitives(gc) gc.pop end
ruby
def add_primitives(gc) #:nodoc: raise ArgumentError, 'RVG width or height undefined' if @width.nil? || @height.nil? return self if @width.zero? || @height.zero? gc.push add_outermost_primitives(gc) gc.pop end
[ "def", "add_primitives", "(", "gc", ")", "#:nodoc:", "raise", "ArgumentError", ",", "'RVG width or height undefined'", "if", "@width", ".", "nil?", "||", "@height", ".", "nil?", "return", "self", "if", "@width", ".", "zero?", "||", "@height", ".", "zero?", "gc...
Primitives for nested RVG objects
[ "Primitives", "for", "nested", "RVG", "objects" ]
ef6688ed9d76bf123c2ea1a483eff8635051adb7
https://github.com/rmagick/rmagick/blob/ef6688ed9d76bf123c2ea1a483eff8635051adb7/lib/rvg/rvg.rb#L271-L278
train
rmagick/rmagick
lib/rmagick_internal.rb
Magick.Geometry.to_s
def to_s str = '' if @width > 0 fmt = @width.truncate == @width ? '%d' : '%.2f' str << format(fmt, @width) str << '%' if @flag == PercentGeometry end str << 'x' if (@width > 0 && @flag != PercentGeometry) || (@height > 0) if @height > 0 fmt = @height.trunc...
ruby
def to_s str = '' if @width > 0 fmt = @width.truncate == @width ? '%d' : '%.2f' str << format(fmt, @width) str << '%' if @flag == PercentGeometry end str << 'x' if (@width > 0 && @flag != PercentGeometry) || (@height > 0) if @height > 0 fmt = @height.trunc...
[ "def", "to_s", "str", "=", "''", "if", "@width", ">", "0", "fmt", "=", "@width", ".", "truncate", "==", "@width", "?", "'%d'", ":", "'%.2f'", "str", "<<", "format", "(", "fmt", ",", "@width", ")", "str", "<<", "'%'", "if", "@flag", "==", "PercentGe...
Convert object to a geometry string
[ "Convert", "object", "to", "a", "geometry", "string" ]
ef6688ed9d76bf123c2ea1a483eff8635051adb7
https://github.com/rmagick/rmagick/blob/ef6688ed9d76bf123c2ea1a483eff8635051adb7/lib/rmagick_internal.rb#L130-L148
train
rmagick/rmagick
lib/rmagick_internal.rb
Magick.Draw.arc
def arc(start_x, start_y, end_x, end_y, start_degrees, end_degrees) primitive 'arc ' + format('%g,%g %g,%g %g,%g', start_x, start_y, end_x, end_y, start_degrees, end_degrees) end
ruby
def arc(start_x, start_y, end_x, end_y, start_degrees, end_degrees) primitive 'arc ' + format('%g,%g %g,%g %g,%g', start_x, start_y, end_x, end_y, start_degrees, end_degrees) end
[ "def", "arc", "(", "start_x", ",", "start_y", ",", "end_x", ",", "end_y", ",", "start_degrees", ",", "end_degrees", ")", "primitive", "'arc '", "+", "format", "(", "'%g,%g %g,%g %g,%g'", ",", "start_x", ",", "start_y", ",", "end_x", ",", "end_y", ",", "sta...
Draw an arc.
[ "Draw", "an", "arc", "." ]
ef6688ed9d76bf123c2ea1a483eff8635051adb7
https://github.com/rmagick/rmagick/blob/ef6688ed9d76bf123c2ea1a483eff8635051adb7/lib/rmagick_internal.rb#L233-L236
train
rmagick/rmagick
lib/rmagick_internal.rb
Magick.Draw.circle
def circle(origin_x, origin_y, perim_x, perim_y) primitive 'circle ' + format('%g,%g %g,%g', origin_x, origin_y, perim_x, perim_y) end
ruby
def circle(origin_x, origin_y, perim_x, perim_y) primitive 'circle ' + format('%g,%g %g,%g', origin_x, origin_y, perim_x, perim_y) end
[ "def", "circle", "(", "origin_x", ",", "origin_y", ",", "perim_x", ",", "perim_y", ")", "primitive", "'circle '", "+", "format", "(", "'%g,%g %g,%g'", ",", "origin_x", ",", "origin_y", ",", "perim_x", ",", "perim_y", ")", "end" ]
Draw a circle
[ "Draw", "a", "circle" ]
ef6688ed9d76bf123c2ea1a483eff8635051adb7
https://github.com/rmagick/rmagick/blob/ef6688ed9d76bf123c2ea1a483eff8635051adb7/lib/rmagick_internal.rb#L249-L251
train
rmagick/rmagick
lib/rmagick_internal.rb
Magick.Draw.clip_rule
def clip_rule(rule) Kernel.raise ArgumentError, "Unknown clipping rule #{rule}" unless %w[evenodd nonzero].include?(rule.downcase) primitive "clip-rule #{rule}" end
ruby
def clip_rule(rule) Kernel.raise ArgumentError, "Unknown clipping rule #{rule}" unless %w[evenodd nonzero].include?(rule.downcase) primitive "clip-rule #{rule}" end
[ "def", "clip_rule", "(", "rule", ")", "Kernel", ".", "raise", "ArgumentError", ",", "\"Unknown clipping rule #{rule}\"", "unless", "%w[", "evenodd", "nonzero", "]", ".", "include?", "(", "rule", ".", "downcase", ")", "primitive", "\"clip-rule #{rule}\"", "end" ]
Define the clipping rule.
[ "Define", "the", "clipping", "rule", "." ]
ef6688ed9d76bf123c2ea1a483eff8635051adb7
https://github.com/rmagick/rmagick/blob/ef6688ed9d76bf123c2ea1a483eff8635051adb7/lib/rmagick_internal.rb#L259-L262
train
rmagick/rmagick
lib/rmagick_internal.rb
Magick.Draw.clip_units
def clip_units(unit) Kernel.raise ArgumentError, "Unknown clip unit #{unit}" unless %w[userspace userspaceonuse objectboundingbox].include?(unit.downcase) primitive "clip-units #{unit}" end
ruby
def clip_units(unit) Kernel.raise ArgumentError, "Unknown clip unit #{unit}" unless %w[userspace userspaceonuse objectboundingbox].include?(unit.downcase) primitive "clip-units #{unit}" end
[ "def", "clip_units", "(", "unit", ")", "Kernel", ".", "raise", "ArgumentError", ",", "\"Unknown clip unit #{unit}\"", "unless", "%w[", "userspace", "userspaceonuse", "objectboundingbox", "]", ".", "include?", "(", "unit", ".", "downcase", ")", "primitive", "\"clip-u...
Define the clip units
[ "Define", "the", "clip", "units" ]
ef6688ed9d76bf123c2ea1a483eff8635051adb7
https://github.com/rmagick/rmagick/blob/ef6688ed9d76bf123c2ea1a483eff8635051adb7/lib/rmagick_internal.rb#L265-L268
train
rmagick/rmagick
lib/rmagick_internal.rb
Magick.Draw.color
def color(x, y, method) Kernel.raise ArgumentError, "Unknown PaintMethod: #{method}" unless PAINT_METHOD_NAMES.key?(method.to_i) primitive "color #{x},#{y},#{PAINT_METHOD_NAMES[method.to_i]}" end
ruby
def color(x, y, method) Kernel.raise ArgumentError, "Unknown PaintMethod: #{method}" unless PAINT_METHOD_NAMES.key?(method.to_i) primitive "color #{x},#{y},#{PAINT_METHOD_NAMES[method.to_i]}" end
[ "def", "color", "(", "x", ",", "y", ",", "method", ")", "Kernel", ".", "raise", "ArgumentError", ",", "\"Unknown PaintMethod: #{method}\"", "unless", "PAINT_METHOD_NAMES", ".", "key?", "(", "method", ".", "to_i", ")", "primitive", "\"color #{x},#{y},#{PAINT_METHOD_N...
Set color in image according to specified colorization rule. Rule is one of point, replace, floodfill, filltoborder,reset
[ "Set", "color", "in", "image", "according", "to", "specified", "colorization", "rule", ".", "Rule", "is", "one", "of", "point", "replace", "floodfill", "filltoborder", "reset" ]
ef6688ed9d76bf123c2ea1a483eff8635051adb7
https://github.com/rmagick/rmagick/blob/ef6688ed9d76bf123c2ea1a483eff8635051adb7/lib/rmagick_internal.rb#L272-L275
train
rmagick/rmagick
lib/rmagick_internal.rb
Magick.Draw.ellipse
def ellipse(origin_x, origin_y, width, height, arc_start, arc_end) primitive 'ellipse ' + format('%g,%g %g,%g %g,%g', origin_x, origin_y, width, height, arc_start, arc_end) end
ruby
def ellipse(origin_x, origin_y, width, height, arc_start, arc_end) primitive 'ellipse ' + format('%g,%g %g,%g %g,%g', origin_x, origin_y, width, height, arc_start, arc_end) end
[ "def", "ellipse", "(", "origin_x", ",", "origin_y", ",", "width", ",", "height", ",", "arc_start", ",", "arc_end", ")", "primitive", "'ellipse '", "+", "format", "(", "'%g,%g %g,%g %g,%g'", ",", "origin_x", ",", "origin_y", ",", "width", ",", "height", ",", ...
Draw an ellipse
[ "Draw", "an", "ellipse" ]
ef6688ed9d76bf123c2ea1a483eff8635051adb7
https://github.com/rmagick/rmagick/blob/ef6688ed9d76bf123c2ea1a483eff8635051adb7/lib/rmagick_internal.rb#L304-L307
train
rmagick/rmagick
lib/rmagick_internal.rb
Magick.Draw.interline_spacing
def interline_spacing(space) begin Float(space) rescue ArgumentError Kernel.raise ArgumentError, 'invalid value for interline_spacing' rescue TypeError Kernel.raise TypeError, "can't convert #{space.class} into Float" end primitive "interline-spacing #{space}" e...
ruby
def interline_spacing(space) begin Float(space) rescue ArgumentError Kernel.raise ArgumentError, 'invalid value for interline_spacing' rescue TypeError Kernel.raise TypeError, "can't convert #{space.class} into Float" end primitive "interline-spacing #{space}" e...
[ "def", "interline_spacing", "(", "space", ")", "begin", "Float", "(", "space", ")", "rescue", "ArgumentError", "Kernel", ".", "raise", "ArgumentError", ",", "'invalid value for interline_spacing'", "rescue", "TypeError", "Kernel", ".", "raise", "TypeError", ",", "\"...
IM 6.5.5-8 and later
[ "IM", "6", ".", "5", ".", "5", "-", "8", "and", "later" ]
ef6688ed9d76bf123c2ea1a483eff8635051adb7
https://github.com/rmagick/rmagick/blob/ef6688ed9d76bf123c2ea1a483eff8635051adb7/lib/rmagick_internal.rb#L369-L378
train
rmagick/rmagick
lib/rmagick_internal.rb
Magick.Draw.line
def line(start_x, start_y, end_x, end_y) primitive 'line ' + format('%g,%g %g,%g', start_x, start_y, end_x, end_y) end
ruby
def line(start_x, start_y, end_x, end_y) primitive 'line ' + format('%g,%g %g,%g', start_x, start_y, end_x, end_y) end
[ "def", "line", "(", "start_x", ",", "start_y", ",", "end_x", ",", "end_y", ")", "primitive", "'line '", "+", "format", "(", "'%g,%g %g,%g'", ",", "start_x", ",", "start_y", ",", "end_x", ",", "end_y", ")", "end" ]
Draw a line
[ "Draw", "a", "line" ]
ef6688ed9d76bf123c2ea1a483eff8635051adb7
https://github.com/rmagick/rmagick/blob/ef6688ed9d76bf123c2ea1a483eff8635051adb7/lib/rmagick_internal.rb#L405-L407
train
rmagick/rmagick
lib/rmagick_internal.rb
Magick.Draw.opacity
def opacity(opacity) if opacity.is_a?(Numeric) Kernel.raise ArgumentError, 'opacity must be >= 0 and <= 1.0' if opacity < 0 || opacity > 1.0 end primitive "opacity #{opacity}" end
ruby
def opacity(opacity) if opacity.is_a?(Numeric) Kernel.raise ArgumentError, 'opacity must be >= 0 and <= 1.0' if opacity < 0 || opacity > 1.0 end primitive "opacity #{opacity}" end
[ "def", "opacity", "(", "opacity", ")", "if", "opacity", ".", "is_a?", "(", "Numeric", ")", "Kernel", ".", "raise", "ArgumentError", ",", "'opacity must be >= 0 and <= 1.0'", "if", "opacity", "<", "0", "||", "opacity", ">", "1.0", "end", "primitive", "\"opacity...
Specify drawing fill and stroke opacities. If the value is a string ending with a %, the number will be multiplied by 0.01.
[ "Specify", "drawing", "fill", "and", "stroke", "opacities", ".", "If", "the", "value", "is", "a", "string", "ending", "with", "a", "%", "the", "number", "will", "be", "multiplied", "by", "0", ".", "01", "." ]
ef6688ed9d76bf123c2ea1a483eff8635051adb7
https://github.com/rmagick/rmagick/blob/ef6688ed9d76bf123c2ea1a483eff8635051adb7/lib/rmagick_internal.rb#L418-L423
train
rmagick/rmagick
lib/rmagick_internal.rb
Magick.Draw.pattern
def pattern(name, x, y, width, height) push('defs') push("pattern #{name} #{x} #{y} #{width} #{height}") push('graphic-context') yield ensure pop('graphic-context') pop('pattern') pop('defs') end
ruby
def pattern(name, x, y, width, height) push('defs') push("pattern #{name} #{x} #{y} #{width} #{height}") push('graphic-context') yield ensure pop('graphic-context') pop('pattern') pop('defs') end
[ "def", "pattern", "(", "name", ",", "x", ",", "y", ",", "width", ",", "height", ")", "push", "(", "'defs'", ")", "push", "(", "\"pattern #{name} #{x} #{y} #{width} #{height}\"", ")", "push", "(", "'graphic-context'", ")", "yield", "ensure", "pop", "(", "'gra...
Define a pattern. In the block, call primitive methods to draw the pattern. Reference the pattern by using its name as the argument to the 'fill' or 'stroke' methods
[ "Define", "a", "pattern", ".", "In", "the", "block", "call", "primitive", "methods", "to", "draw", "the", "pattern", ".", "Reference", "the", "pattern", "by", "using", "its", "name", "as", "the", "argument", "to", "the", "fill", "or", "stroke", "methods" ]
ef6688ed9d76bf123c2ea1a483eff8635051adb7
https://github.com/rmagick/rmagick/blob/ef6688ed9d76bf123c2ea1a483eff8635051adb7/lib/rmagick_internal.rb#L435-L444
train
rmagick/rmagick
lib/rmagick_internal.rb
Magick.Draw.polygon
def polygon(*points) if points.length.zero? Kernel.raise ArgumentError, 'no points specified' elsif points.length.odd? Kernel.raise ArgumentError, 'odd number of points specified' end primitive 'polygon ' + points.join(',') end
ruby
def polygon(*points) if points.length.zero? Kernel.raise ArgumentError, 'no points specified' elsif points.length.odd? Kernel.raise ArgumentError, 'odd number of points specified' end primitive 'polygon ' + points.join(',') end
[ "def", "polygon", "(", "*", "points", ")", "if", "points", ".", "length", ".", "zero?", "Kernel", ".", "raise", "ArgumentError", ",", "'no points specified'", "elsif", "points", ".", "length", ".", "odd?", "Kernel", ".", "raise", "ArgumentError", ",", "'odd ...
Draw a polygon
[ "Draw", "a", "polygon" ]
ef6688ed9d76bf123c2ea1a483eff8635051adb7
https://github.com/rmagick/rmagick/blob/ef6688ed9d76bf123c2ea1a483eff8635051adb7/lib/rmagick_internal.rb#L459-L466
train
rmagick/rmagick
lib/rmagick_internal.rb
Magick.Draw.rectangle
def rectangle(upper_left_x, upper_left_y, lower_right_x, lower_right_y) primitive 'rectangle ' + format('%g,%g %g,%g', upper_left_x, upper_left_y, lower_right_x, lower_right_y) end
ruby
def rectangle(upper_left_x, upper_left_y, lower_right_x, lower_right_y) primitive 'rectangle ' + format('%g,%g %g,%g', upper_left_x, upper_left_y, lower_right_x, lower_right_y) end
[ "def", "rectangle", "(", "upper_left_x", ",", "upper_left_y", ",", "lower_right_x", ",", "lower_right_y", ")", "primitive", "'rectangle '", "+", "format", "(", "'%g,%g %g,%g'", ",", "upper_left_x", ",", "upper_left_y", ",", "lower_right_x", ",", "lower_right_y", ")"...
Draw a rectangle
[ "Draw", "a", "rectangle" ]
ef6688ed9d76bf123c2ea1a483eff8635051adb7
https://github.com/rmagick/rmagick/blob/ef6688ed9d76bf123c2ea1a483eff8635051adb7/lib/rmagick_internal.rb#L508-L511
train
rmagick/rmagick
lib/rmagick_internal.rb
Magick.Draw.roundrectangle
def roundrectangle(center_x, center_y, width, height, corner_width, corner_height) primitive 'roundrectangle ' + format('%g,%g,%g,%g,%g,%g', center_x, center_y, width, height, corner_width, corner_height) end
ruby
def roundrectangle(center_x, center_y, width, height, corner_width, corner_height) primitive 'roundrectangle ' + format('%g,%g,%g,%g,%g,%g', center_x, center_y, width, height, corner_width, corner_height) end
[ "def", "roundrectangle", "(", "center_x", ",", "center_y", ",", "width", ",", "height", ",", "corner_width", ",", "corner_height", ")", "primitive", "'roundrectangle '", "+", "format", "(", "'%g,%g,%g,%g,%g,%g'", ",", "center_x", ",", "center_y", ",", "width", "...
Draw a rectangle with rounded corners
[ "Draw", "a", "rectangle", "with", "rounded", "corners" ]
ef6688ed9d76bf123c2ea1a483eff8635051adb7
https://github.com/rmagick/rmagick/blob/ef6688ed9d76bf123c2ea1a483eff8635051adb7/lib/rmagick_internal.rb#L519-L522
train
rmagick/rmagick
lib/rmagick_internal.rb
Magick.Draw.stroke_dasharray
def stroke_dasharray(*list) if list.length.zero? primitive 'stroke-dasharray none' else list.each do |x| Kernel.raise ArgumentError, "dash array elements must be > 0 (#{x} given)" if x <= 0 end primitive "stroke-dasharray #{list.join(',')}" end end
ruby
def stroke_dasharray(*list) if list.length.zero? primitive 'stroke-dasharray none' else list.each do |x| Kernel.raise ArgumentError, "dash array elements must be > 0 (#{x} given)" if x <= 0 end primitive "stroke-dasharray #{list.join(',')}" end end
[ "def", "stroke_dasharray", "(", "*", "list", ")", "if", "list", ".", "length", ".", "zero?", "primitive", "'stroke-dasharray none'", "else", "list", ".", "each", "do", "|", "x", "|", "Kernel", ".", "raise", "ArgumentError", ",", "\"dash array elements must be > ...
Specify a stroke dash pattern
[ "Specify", "a", "stroke", "dash", "pattern" ]
ef6688ed9d76bf123c2ea1a483eff8635051adb7
https://github.com/rmagick/rmagick/blob/ef6688ed9d76bf123c2ea1a483eff8635051adb7/lib/rmagick_internal.rb#L551-L560
train
rmagick/rmagick
lib/rmagick_internal.rb
Magick.Draw.text
def text(x, y, text) Kernel.raise ArgumentError, 'missing text argument' if text.to_s.empty? if text.length > 2 && /\A(?:\"[^\"]+\"|\'[^\']+\'|\{[^\}]+\})\z/.match(text) # text already quoted elsif !text['\''] text = '\'' + text + '\'' elsif !text['"'] text = '"' + text + '...
ruby
def text(x, y, text) Kernel.raise ArgumentError, 'missing text argument' if text.to_s.empty? if text.length > 2 && /\A(?:\"[^\"]+\"|\'[^\']+\'|\{[^\}]+\})\z/.match(text) # text already quoted elsif !text['\''] text = '\'' + text + '\'' elsif !text['"'] text = '"' + text + '...
[ "def", "text", "(", "x", ",", "y", ",", "text", ")", "Kernel", ".", "raise", "ArgumentError", ",", "'missing text argument'", "if", "text", ".", "to_s", ".", "empty?", "if", "text", ".", "length", ">", "2", "&&", "/", "\\A", "\\\"", "\\\"", "\\\"", "...
Draw text at position x,y. Add quotes to text that is not already quoted.
[ "Draw", "text", "at", "position", "x", "y", ".", "Add", "quotes", "to", "text", "that", "is", "not", "already", "quoted", "." ]
ef6688ed9d76bf123c2ea1a483eff8635051adb7
https://github.com/rmagick/rmagick/blob/ef6688ed9d76bf123c2ea1a483eff8635051adb7/lib/rmagick_internal.rb#L594-L609
train
rmagick/rmagick
lib/rmagick_internal.rb
Magick.Draw.text_align
def text_align(alignment) Kernel.raise ArgumentError, "Unknown alignment constant: #{alignment}" unless ALIGN_TYPE_NAMES.key?(alignment.to_i) primitive "text-align #{ALIGN_TYPE_NAMES[alignment.to_i]}" end
ruby
def text_align(alignment) Kernel.raise ArgumentError, "Unknown alignment constant: #{alignment}" unless ALIGN_TYPE_NAMES.key?(alignment.to_i) primitive "text-align #{ALIGN_TYPE_NAMES[alignment.to_i]}" end
[ "def", "text_align", "(", "alignment", ")", "Kernel", ".", "raise", "ArgumentError", ",", "\"Unknown alignment constant: #{alignment}\"", "unless", "ALIGN_TYPE_NAMES", ".", "key?", "(", "alignment", ".", "to_i", ")", "primitive", "\"text-align #{ALIGN_TYPE_NAMES[alignment.t...
Specify text alignment relative to a given point
[ "Specify", "text", "alignment", "relative", "to", "a", "given", "point" ]
ef6688ed9d76bf123c2ea1a483eff8635051adb7
https://github.com/rmagick/rmagick/blob/ef6688ed9d76bf123c2ea1a483eff8635051adb7/lib/rmagick_internal.rb#L612-L615
train
rmagick/rmagick
lib/rmagick_internal.rb
Magick.Draw.text_anchor
def text_anchor(anchor) Kernel.raise ArgumentError, "Unknown anchor constant: #{anchor}" unless ANCHOR_TYPE_NAMES.key?(anchor.to_i) primitive "text-anchor #{ANCHOR_TYPE_NAMES[anchor.to_i]}" end
ruby
def text_anchor(anchor) Kernel.raise ArgumentError, "Unknown anchor constant: #{anchor}" unless ANCHOR_TYPE_NAMES.key?(anchor.to_i) primitive "text-anchor #{ANCHOR_TYPE_NAMES[anchor.to_i]}" end
[ "def", "text_anchor", "(", "anchor", ")", "Kernel", ".", "raise", "ArgumentError", ",", "\"Unknown anchor constant: #{anchor}\"", "unless", "ANCHOR_TYPE_NAMES", ".", "key?", "(", "anchor", ".", "to_i", ")", "primitive", "\"text-anchor #{ANCHOR_TYPE_NAMES[anchor.to_i]}\"", ...
SVG-compatible version of text_align
[ "SVG", "-", "compatible", "version", "of", "text_align" ]
ef6688ed9d76bf123c2ea1a483eff8635051adb7
https://github.com/rmagick/rmagick/blob/ef6688ed9d76bf123c2ea1a483eff8635051adb7/lib/rmagick_internal.rb#L618-L621
train
rmagick/rmagick
lib/rmagick_internal.rb
Magick.Image.color_point
def color_point(x, y, fill) f = copy f.pixel_color(x, y, fill) f end
ruby
def color_point(x, y, fill) f = copy f.pixel_color(x, y, fill) f end
[ "def", "color_point", "(", "x", ",", "y", ",", "fill", ")", "f", "=", "copy", "f", ".", "pixel_color", "(", "x", ",", "y", ",", "fill", ")", "f", "end" ]
Set the color at x,y
[ "Set", "the", "color", "at", "x", "y" ]
ef6688ed9d76bf123c2ea1a483eff8635051adb7
https://github.com/rmagick/rmagick/blob/ef6688ed9d76bf123c2ea1a483eff8635051adb7/lib/rmagick_internal.rb#L763-L767
train
rmagick/rmagick
lib/rmagick_internal.rb
Magick.Image.color_floodfill
def color_floodfill(x, y, fill) target = pixel_color(x, y) color_flood_fill(target, fill, x, y, Magick::FloodfillMethod) end
ruby
def color_floodfill(x, y, fill) target = pixel_color(x, y) color_flood_fill(target, fill, x, y, Magick::FloodfillMethod) end
[ "def", "color_floodfill", "(", "x", ",", "y", ",", "fill", ")", "target", "=", "pixel_color", "(", "x", ",", "y", ")", "color_flood_fill", "(", "target", ",", "fill", ",", "x", ",", "y", ",", "Magick", "::", "FloodfillMethod", ")", "end" ]
Set all pixels that have the same color as the pixel at x,y and are neighbors to the fill color
[ "Set", "all", "pixels", "that", "have", "the", "same", "color", "as", "the", "pixel", "at", "x", "y", "and", "are", "neighbors", "to", "the", "fill", "color" ]
ef6688ed9d76bf123c2ea1a483eff8635051adb7
https://github.com/rmagick/rmagick/blob/ef6688ed9d76bf123c2ea1a483eff8635051adb7/lib/rmagick_internal.rb#L771-L774
train
rmagick/rmagick
lib/rmagick_internal.rb
Magick.Image.color_fill_to_border
def color_fill_to_border(x, y, fill) color_flood_fill(border_color, fill, x, y, Magick::FillToBorderMethod) end
ruby
def color_fill_to_border(x, y, fill) color_flood_fill(border_color, fill, x, y, Magick::FillToBorderMethod) end
[ "def", "color_fill_to_border", "(", "x", ",", "y", ",", "fill", ")", "color_flood_fill", "(", "border_color", ",", "fill", ",", "x", ",", "y", ",", "Magick", "::", "FillToBorderMethod", ")", "end" ]
Set all pixels that are neighbors of x,y and are not the border color to the fill color
[ "Set", "all", "pixels", "that", "are", "neighbors", "of", "x", "y", "and", "are", "not", "the", "border", "color", "to", "the", "fill", "color" ]
ef6688ed9d76bf123c2ea1a483eff8635051adb7
https://github.com/rmagick/rmagick/blob/ef6688ed9d76bf123c2ea1a483eff8635051adb7/lib/rmagick_internal.rb#L778-L780
train
rmagick/rmagick
lib/rmagick_internal.rb
Magick.Image.each_pixel
def each_pixel get_pixels(0, 0, columns, rows).each_with_index do |p, n| yield(p, n % columns, n / columns) end self end
ruby
def each_pixel get_pixels(0, 0, columns, rows).each_with_index do |p, n| yield(p, n % columns, n / columns) end self end
[ "def", "each_pixel", "get_pixels", "(", "0", ",", "0", ",", "columns", ",", "rows", ")", ".", "each_with_index", "do", "|", "p", ",", "n", "|", "yield", "(", "p", ",", "n", "%", "columns", ",", "n", "/", "columns", ")", "end", "self", "end" ]
Thanks to Russell Norris!
[ "Thanks", "to", "Russell", "Norris!" ]
ef6688ed9d76bf123c2ea1a483eff8635051adb7
https://github.com/rmagick/rmagick/blob/ef6688ed9d76bf123c2ea1a483eff8635051adb7/lib/rmagick_internal.rb#L804-L809
train
rmagick/rmagick
lib/rmagick_internal.rb
Magick.Image.matte_fill_to_border
def matte_fill_to_border(x, y) f = copy f.opacity = Magick::OpaqueOpacity unless f.alpha? f.matte_flood_fill(border_color, TransparentOpacity, x, y, FillToBorderMethod) end
ruby
def matte_fill_to_border(x, y) f = copy f.opacity = Magick::OpaqueOpacity unless f.alpha? f.matte_flood_fill(border_color, TransparentOpacity, x, y, FillToBorderMethod) end
[ "def", "matte_fill_to_border", "(", "x", ",", "y", ")", "f", "=", "copy", "f", ".", "opacity", "=", "Magick", "::", "OpaqueOpacity", "unless", "f", ".", "alpha?", "f", ".", "matte_flood_fill", "(", "border_color", ",", "TransparentOpacity", ",", "x", ",", ...
Make transparent any neighbor pixel that is not the border color.
[ "Make", "transparent", "any", "neighbor", "pixel", "that", "is", "not", "the", "border", "color", "." ]
ef6688ed9d76bf123c2ea1a483eff8635051adb7
https://github.com/rmagick/rmagick/blob/ef6688ed9d76bf123c2ea1a483eff8635051adb7/lib/rmagick_internal.rb#L935-L940
train
rmagick/rmagick
lib/rmagick_internal.rb
Magick.Image.texture_floodfill
def texture_floodfill(x, y, texture) target = pixel_color(x, y) texture_flood_fill(target, texture, x, y, FloodfillMethod) end
ruby
def texture_floodfill(x, y, texture) target = pixel_color(x, y) texture_flood_fill(target, texture, x, y, FloodfillMethod) end
[ "def", "texture_floodfill", "(", "x", ",", "y", ",", "texture", ")", "target", "=", "pixel_color", "(", "x", ",", "y", ")", "texture_flood_fill", "(", "target", ",", "texture", ",", "x", ",", "y", ",", "FloodfillMethod", ")", "end" ]
Replace matching neighboring pixels with texture pixels
[ "Replace", "matching", "neighboring", "pixels", "with", "texture", "pixels" ]
ef6688ed9d76bf123c2ea1a483eff8635051adb7
https://github.com/rmagick/rmagick/blob/ef6688ed9d76bf123c2ea1a483eff8635051adb7/lib/rmagick_internal.rb#L985-L988
train
rmagick/rmagick
lib/rmagick_internal.rb
Magick.Image.texture_fill_to_border
def texture_fill_to_border(x, y, texture) texture_flood_fill(border_color, texture, x, y, FillToBorderMethod) end
ruby
def texture_fill_to_border(x, y, texture) texture_flood_fill(border_color, texture, x, y, FillToBorderMethod) end
[ "def", "texture_fill_to_border", "(", "x", ",", "y", ",", "texture", ")", "texture_flood_fill", "(", "border_color", ",", "texture", ",", "x", ",", "y", ",", "FillToBorderMethod", ")", "end" ]
Replace neighboring pixels to border color with texture pixels
[ "Replace", "neighboring", "pixels", "to", "border", "color", "with", "texture", "pixels" ]
ef6688ed9d76bf123c2ea1a483eff8635051adb7
https://github.com/rmagick/rmagick/blob/ef6688ed9d76bf123c2ea1a483eff8635051adb7/lib/rmagick_internal.rb#L991-L993
train
rmagick/rmagick
lib/rmagick_internal.rb
Magick.Image.view
def view(x, y, width, height) view = View.new(self, x, y, width, height) return view unless block_given? begin yield(view) ensure view.sync end nil end
ruby
def view(x, y, width, height) view = View.new(self, x, y, width, height) return view unless block_given? begin yield(view) ensure view.sync end nil end
[ "def", "view", "(", "x", ",", "y", ",", "width", ",", "height", ")", "view", "=", "View", ".", "new", "(", "self", ",", "x", ",", "y", ",", "width", ",", "height", ")", "return", "view", "unless", "block_given?", "begin", "yield", "(", "view", ")...
Construct a view. If a block is present, yield and pass the view object, otherwise return the view object.
[ "Construct", "a", "view", ".", "If", "a", "block", "is", "present", "yield", "and", "pass", "the", "view", "object", "otherwise", "return", "the", "view", "object", "." ]
ef6688ed9d76bf123c2ea1a483eff8635051adb7
https://github.com/rmagick/rmagick/blob/ef6688ed9d76bf123c2ea1a483eff8635051adb7/lib/rmagick_internal.rb#L997-L1008
train
rmagick/rmagick
lib/rmagick_internal.rb
Magick.ImageList.set_current
def set_current(current) if length.zero? self.scene = nil return # Don't bother looking for current image elsif scene.nil? || scene >= length self.scene = length - 1 return elsif !current.nil? # Find last instance of "current" in the list. # If "cu...
ruby
def set_current(current) if length.zero? self.scene = nil return # Don't bother looking for current image elsif scene.nil? || scene >= length self.scene = length - 1 return elsif !current.nil? # Find last instance of "current" in the list. # If "cu...
[ "def", "set_current", "(", "current", ")", "if", "length", ".", "zero?", "self", ".", "scene", "=", "nil", "return", "# Don't bother looking for current image", "elsif", "scene", ".", "nil?", "||", "scene", ">=", "length", "self", ".", "scene", "=", "length", ...
Find old current image, update scene number current is the id of the old current image.
[ "Find", "old", "current", "image", "update", "scene", "number", "current", "is", "the", "id", "of", "the", "old", "current", "image", "." ]
ef6688ed9d76bf123c2ea1a483eff8635051adb7
https://github.com/rmagick/rmagick/blob/ef6688ed9d76bf123c2ea1a483eff8635051adb7/lib/rmagick_internal.rb#L1248-L1266
train
rmagick/rmagick
lib/rmagick_internal.rb
Magick.ImageList.scene=
def scene=(n) if n.nil? Kernel.raise IndexError, 'scene number out of bounds' unless @images.length.zero? @scene = nil return @scene elsif @images.length.zero? Kernel.raise IndexError, 'scene number out of bounds' end n = Integer(n) Kernel.raise IndexError,...
ruby
def scene=(n) if n.nil? Kernel.raise IndexError, 'scene number out of bounds' unless @images.length.zero? @scene = nil return @scene elsif @images.length.zero? Kernel.raise IndexError, 'scene number out of bounds' end n = Integer(n) Kernel.raise IndexError,...
[ "def", "scene", "=", "(", "n", ")", "if", "n", ".", "nil?", "Kernel", ".", "raise", "IndexError", ",", "'scene number out of bounds'", "unless", "@images", ".", "length", ".", "zero?", "@scene", "=", "nil", "return", "@scene", "elsif", "@images", ".", "len...
Allow scene to be set to nil
[ "Allow", "scene", "to", "be", "set", "to", "nil" ]
ef6688ed9d76bf123c2ea1a483eff8635051adb7
https://github.com/rmagick/rmagick/blob/ef6688ed9d76bf123c2ea1a483eff8635051adb7/lib/rmagick_internal.rb#L1271-L1284
train
rmagick/rmagick
lib/rmagick_internal.rb
Magick.ImageList.copy
def copy ditto = self.class.new @images.each { |f| ditto << f.copy } ditto.scene = @scene ditto.taint if tainted? ditto end
ruby
def copy ditto = self.class.new @images.each { |f| ditto << f.copy } ditto.scene = @scene ditto.taint if tainted? ditto end
[ "def", "copy", "ditto", "=", "self", ".", "class", ".", "new", "@images", ".", "each", "{", "|", "f", "|", "ditto", "<<", "f", ".", "copy", "}", "ditto", ".", "scene", "=", "@scene", "ditto", ".", "taint", "if", "tainted?", "ditto", "end" ]
Make a deep copy
[ "Make", "a", "deep", "copy" ]
ef6688ed9d76bf123c2ea1a483eff8635051adb7
https://github.com/rmagick/rmagick/blob/ef6688ed9d76bf123c2ea1a483eff8635051adb7/lib/rmagick_internal.rb#L1415-L1421
train
rmagick/rmagick
lib/rmagick_internal.rb
Magick.ImageList.delay=
def delay=(d) raise ArgumentError, 'delay must be greater than or equal to 0' if Integer(d) < 0 @images.each { |f| f.delay = Integer(d) } end
ruby
def delay=(d) raise ArgumentError, 'delay must be greater than or equal to 0' if Integer(d) < 0 @images.each { |f| f.delay = Integer(d) } end
[ "def", "delay", "=", "(", "d", ")", "raise", "ArgumentError", ",", "'delay must be greater than or equal to 0'", "if", "Integer", "(", "d", ")", "<", "0", "@images", ".", "each", "{", "|", "f", "|", "f", ".", "delay", "=", "Integer", "(", "d", ")", "}"...
Set same delay for all images
[ "Set", "same", "delay", "for", "all", "images" ]
ef6688ed9d76bf123c2ea1a483eff8635051adb7
https://github.com/rmagick/rmagick/blob/ef6688ed9d76bf123c2ea1a483eff8635051adb7/lib/rmagick_internal.rb#L1461-L1465
train
rmagick/rmagick
lib/rmagick_internal.rb
Magick.ImageList.insert
def insert(index, *args) args.each { |image| is_an_image image } current = get_current @images.insert(index, *args) set_current current self end
ruby
def insert(index, *args) args.each { |image| is_an_image image } current = get_current @images.insert(index, *args) set_current current self end
[ "def", "insert", "(", "index", ",", "*", "args", ")", "args", ".", "each", "{", "|", "image", "|", "is_an_image", "image", "}", "current", "=", "get_current", "@images", ".", "insert", "(", "index", ",", "args", ")", "set_current", "current", "self", "...
Initialize new instances
[ "Initialize", "new", "instances" ]
ef6688ed9d76bf123c2ea1a483eff8635051adb7
https://github.com/rmagick/rmagick/blob/ef6688ed9d76bf123c2ea1a483eff8635051adb7/lib/rmagick_internal.rb#L1550-L1556
train
rmagick/rmagick
lib/rmagick_internal.rb
Magick.ImageList.inspect
def inspect img = [] @images.each { |image| img << image.inspect } img = '[' + img.join(",\n") + "]\nscene=#{@scene}" end
ruby
def inspect img = [] @images.each { |image| img << image.inspect } img = '[' + img.join(",\n") + "]\nscene=#{@scene}" end
[ "def", "inspect", "img", "=", "[", "]", "@images", ".", "each", "{", "|", "image", "|", "img", "<<", "image", ".", "inspect", "}", "img", "=", "'['", "+", "img", ".", "join", "(", "\",\\n\"", ")", "+", "\"]\\nscene=#{@scene}\"", "end" ]
Call inspect for all the images
[ "Call", "inspect", "for", "all", "the", "images" ]
ef6688ed9d76bf123c2ea1a483eff8635051adb7
https://github.com/rmagick/rmagick/blob/ef6688ed9d76bf123c2ea1a483eff8635051adb7/lib/rmagick_internal.rb#L1559-L1563
train
rmagick/rmagick
lib/rmagick_internal.rb
Magick.ImageList.iterations=
def iterations=(n) n = Integer(n) Kernel.raise ArgumentError, 'iterations must be between 0 and 65535' if n < 0 || n > 65_535 @images.each { |f| f.iterations = n } self end
ruby
def iterations=(n) n = Integer(n) Kernel.raise ArgumentError, 'iterations must be between 0 and 65535' if n < 0 || n > 65_535 @images.each { |f| f.iterations = n } self end
[ "def", "iterations", "=", "(", "n", ")", "n", "=", "Integer", "(", "n", ")", "Kernel", ".", "raise", "ArgumentError", ",", "'iterations must be between 0 and 65535'", "if", "n", "<", "0", "||", "n", ">", "65_535", "@images", ".", "each", "{", "|", "f", ...
Set the number of iterations of an animated GIF
[ "Set", "the", "number", "of", "iterations", "of", "an", "animated", "GIF" ]
ef6688ed9d76bf123c2ea1a483eff8635051adb7
https://github.com/rmagick/rmagick/blob/ef6688ed9d76bf123c2ea1a483eff8635051adb7/lib/rmagick_internal.rb#L1566-L1571
train
rmagick/rmagick
lib/rmagick_internal.rb
Magick.ImageList.new_image
def new_image(cols, rows, *fill, &info_blk) self << Magick::Image.new(cols, rows, *fill, &info_blk) end
ruby
def new_image(cols, rows, *fill, &info_blk) self << Magick::Image.new(cols, rows, *fill, &info_blk) end
[ "def", "new_image", "(", "cols", ",", "rows", ",", "*", "fill", ",", "&", "info_blk", ")", "self", "<<", "Magick", "::", "Image", ".", "new", "(", "cols", ",", "rows", ",", "fill", ",", "info_blk", ")", "end" ]
Create a new image and add it to the end
[ "Create", "a", "new", "image", "and", "add", "it", "to", "the", "end" ]
ef6688ed9d76bf123c2ea1a483eff8635051adb7
https://github.com/rmagick/rmagick/blob/ef6688ed9d76bf123c2ea1a483eff8635051adb7/lib/rmagick_internal.rb#L1617-L1619
train
rmagick/rmagick
lib/rmagick_internal.rb
Magick.ImageList.read
def read(*files, &block) Kernel.raise ArgumentError, 'no files given' if files.length.zero? files.each do |f| Magick::Image.read(f, &block).each { |n| @images << n } end @scene = length - 1 self end
ruby
def read(*files, &block) Kernel.raise ArgumentError, 'no files given' if files.length.zero? files.each do |f| Magick::Image.read(f, &block).each { |n| @images << n } end @scene = length - 1 self end
[ "def", "read", "(", "*", "files", ",", "&", "block", ")", "Kernel", ".", "raise", "ArgumentError", ",", "'no files given'", "if", "files", ".", "length", ".", "zero?", "files", ".", "each", "do", "|", "f", "|", "Magick", "::", "Image", ".", "read", "...
Read files and concatenate the new images
[ "Read", "files", "and", "concatenate", "the", "new", "images" ]
ef6688ed9d76bf123c2ea1a483eff8635051adb7
https://github.com/rmagick/rmagick/blob/ef6688ed9d76bf123c2ea1a483eff8635051adb7/lib/rmagick_internal.rb#L1659-L1666
train
rmagick/rmagick
lib/rmagick_internal.rb
Magick.ImageList.reject
def reject(&block) current = get_current ilist = self.class.new a = @images.reject(&block) a.each { |image| ilist << image } ilist.set_current current ilist end
ruby
def reject(&block) current = get_current ilist = self.class.new a = @images.reject(&block) a.each { |image| ilist << image } ilist.set_current current ilist end
[ "def", "reject", "(", "&", "block", ")", "current", "=", "get_current", "ilist", "=", "self", ".", "class", ".", "new", "a", "=", "@images", ".", "reject", "(", "block", ")", "a", ".", "each", "{", "|", "image", "|", "ilist", "<<", "image", "}", ...
override Enumerable's reject
[ "override", "Enumerable", "s", "reject" ]
ef6688ed9d76bf123c2ea1a483eff8635051adb7
https://github.com/rmagick/rmagick/blob/ef6688ed9d76bf123c2ea1a483eff8635051adb7/lib/rmagick_internal.rb#L1669-L1676
train
rmagick/rmagick
examples/histogram.rb
Magick.Image.alpha_hist
def alpha_hist(freqs, scale, fg, bg) histogram = Image.new(HISTOGRAM_COLS, HISTOGRAM_ROWS) do self.background_color = bg self.border_color = fg end gc = Draw.new gc.affine(1, 0, 0, -scale, 0, HISTOGRAM_ROWS) gc.fill('white') HISTOGRAM_COLS.times do |x| gc.po...
ruby
def alpha_hist(freqs, scale, fg, bg) histogram = Image.new(HISTOGRAM_COLS, HISTOGRAM_ROWS) do self.background_color = bg self.border_color = fg end gc = Draw.new gc.affine(1, 0, 0, -scale, 0, HISTOGRAM_ROWS) gc.fill('white') HISTOGRAM_COLS.times do |x| gc.po...
[ "def", "alpha_hist", "(", "freqs", ",", "scale", ",", "fg", ",", "bg", ")", "histogram", "=", "Image", ".", "new", "(", "HISTOGRAM_COLS", ",", "HISTOGRAM_ROWS", ")", "do", "self", ".", "background_color", "=", "bg", "self", ".", "border_color", "=", "fg"...
The alpha frequencies are shown as white dots.
[ "The", "alpha", "frequencies", "are", "shown", "as", "white", "dots", "." ]
ef6688ed9d76bf123c2ea1a483eff8635051adb7
https://github.com/rmagick/rmagick/blob/ef6688ed9d76bf123c2ea1a483eff8635051adb7/examples/histogram.rb#L37-L55
train
rmagick/rmagick
examples/histogram.rb
Magick.Image.color_hist
def color_hist(fg, bg) img = number_colors > 256 ? quantize(256) : self begin hist = img.color_histogram rescue NotImplementedError warn 'The color_histogram method is not supported by this version '\ 'of ImageMagick/GraphicsMagick' else pixels = his...
ruby
def color_hist(fg, bg) img = number_colors > 256 ? quantize(256) : self begin hist = img.color_histogram rescue NotImplementedError warn 'The color_histogram method is not supported by this version '\ 'of ImageMagick/GraphicsMagick' else pixels = his...
[ "def", "color_hist", "(", "fg", ",", "bg", ")", "img", "=", "number_colors", ">", "256", "?", "quantize", "(", "256", ")", ":", "self", "begin", "hist", "=", "img", ".", "color_histogram", "rescue", "NotImplementedError", "warn", "'The color_histogram method i...
Make the color histogram. Quantize the image to 256 colors if necessary.
[ "Make", "the", "color", "histogram", ".", "Quantize", "the", "image", "to", "256", "colors", "if", "necessary", "." ]
ef6688ed9d76bf123c2ea1a483eff8635051adb7
https://github.com/rmagick/rmagick/blob/ef6688ed9d76bf123c2ea1a483eff8635051adb7/examples/histogram.rb#L119-L149
train
rmagick/rmagick
examples/histogram.rb
Magick.Image.pixel_intensity
def pixel_intensity(pixel) (306 * (pixel.red & MAX_QUANTUM) + 601 * (pixel.green & MAX_QUANTUM) + 117 * (pixel.blue & MAX_QUANTUM)) / 1024 end
ruby
def pixel_intensity(pixel) (306 * (pixel.red & MAX_QUANTUM) + 601 * (pixel.green & MAX_QUANTUM) + 117 * (pixel.blue & MAX_QUANTUM)) / 1024 end
[ "def", "pixel_intensity", "(", "pixel", ")", "(", "306", "*", "(", "pixel", ".", "red", "&", "MAX_QUANTUM", ")", "+", "601", "*", "(", "pixel", ".", "green", "&", "MAX_QUANTUM", ")", "+", "117", "*", "(", "pixel", ".", "blue", "&", "MAX_QUANTUM", "...
Returns a value between 0 and MAX_QUANTUM. Same as the PixelIntensity macro.
[ "Returns", "a", "value", "between", "0", "and", "MAX_QUANTUM", ".", "Same", "as", "the", "PixelIntensity", "macro", "." ]
ef6688ed9d76bf123c2ea1a483eff8635051adb7
https://github.com/rmagick/rmagick/blob/ef6688ed9d76bf123c2ea1a483eff8635051adb7/examples/histogram.rb#L190-L192
train
rmagick/rmagick
examples/histogram.rb
Magick.Image.histogram
def histogram(fg = 'white', bg = 'black') red = Array.new(HISTOGRAM_COLS, 0) green = Array.new(HISTOGRAM_COLS, 0) blue = Array.new(HISTOGRAM_COLS, 0) alpha = Array.new(HISTOGRAM_COLS, 0) int = Array.new(HISTOGRAM_COLS, 0) rows.times do |row| pixels = get_pixels(0, row, ...
ruby
def histogram(fg = 'white', bg = 'black') red = Array.new(HISTOGRAM_COLS, 0) green = Array.new(HISTOGRAM_COLS, 0) blue = Array.new(HISTOGRAM_COLS, 0) alpha = Array.new(HISTOGRAM_COLS, 0) int = Array.new(HISTOGRAM_COLS, 0) rows.times do |row| pixels = get_pixels(0, row, ...
[ "def", "histogram", "(", "fg", "=", "'white'", ",", "bg", "=", "'black'", ")", "red", "=", "Array", ".", "new", "(", "HISTOGRAM_COLS", ",", "0", ")", "green", "=", "Array", ".", "new", "(", "HISTOGRAM_COLS", ",", "0", ")", "blue", "=", "Array", "."...
Create the histogram montage.
[ "Create", "the", "histogram", "montage", "." ]
ef6688ed9d76bf123c2ea1a483eff8635051adb7
https://github.com/rmagick/rmagick/blob/ef6688ed9d76bf123c2ea1a483eff8635051adb7/examples/histogram.rb#L197-L267
train
petergoldstein/dalli
lib/dalli/cas/client.rb
Dalli.Client.get_cas
def get_cas(key) (value, cas) = perform(:cas, key) value = (!value || value == 'Not found') ? nil : value if block_given? yield value, cas else [value, cas] end end
ruby
def get_cas(key) (value, cas) = perform(:cas, key) value = (!value || value == 'Not found') ? nil : value if block_given? yield value, cas else [value, cas] end end
[ "def", "get_cas", "(", "key", ")", "(", "value", ",", "cas", ")", "=", "perform", "(", ":cas", ",", "key", ")", "value", "=", "(", "!", "value", "||", "value", "==", "'Not found'", ")", "?", "nil", ":", "value", "if", "block_given?", "yield", "valu...
Get the value and CAS ID associated with the key. If a block is provided, value and CAS will be passed to the block.
[ "Get", "the", "value", "and", "CAS", "ID", "associated", "with", "the", "key", ".", "If", "a", "block", "is", "provided", "value", "and", "CAS", "will", "be", "passed", "to", "the", "block", "." ]
5755dbfd06e333a8239f976d4b10492b4555b726
https://github.com/petergoldstein/dalli/blob/5755dbfd06e333a8239f976d4b10492b4555b726/lib/dalli/cas/client.rb#L9-L17
train
petergoldstein/dalli
lib/dalli/cas/client.rb
Dalli.Client.set_cas
def set_cas(key, value, cas, ttl=nil, options=nil) ttl ||= @options[:expires_in].to_i perform(:set, key, value, ttl, cas, options) end
ruby
def set_cas(key, value, cas, ttl=nil, options=nil) ttl ||= @options[:expires_in].to_i perform(:set, key, value, ttl, cas, options) end
[ "def", "set_cas", "(", "key", ",", "value", ",", "cas", ",", "ttl", "=", "nil", ",", "options", "=", "nil", ")", "ttl", "||=", "@options", "[", ":expires_in", "]", ".", "to_i", "perform", "(", ":set", ",", "key", ",", "value", ",", "ttl", ",", "c...
Set the key-value pair, verifying existing CAS. Returns the resulting CAS value if succeeded, and falsy otherwise.
[ "Set", "the", "key", "-", "value", "pair", "verifying", "existing", "CAS", ".", "Returns", "the", "resulting", "CAS", "value", "if", "succeeded", "and", "falsy", "otherwise", "." ]
5755dbfd06e333a8239f976d4b10492b4555b726
https://github.com/petergoldstein/dalli/blob/5755dbfd06e333a8239f976d4b10492b4555b726/lib/dalli/cas/client.rb#L38-L41
train
petergoldstein/dalli
lib/dalli/client.rb
Dalli.Client.fetch
def fetch(key, ttl=nil, options=nil) options = options.nil? ? CACHE_NILS : options.merge(CACHE_NILS) if @options[:cache_nils] val = get(key, options) not_found = @options[:cache_nils] ? val == Dalli::Server::NOT_FOUND : val.nil? if not_found && block_given? val = yield ...
ruby
def fetch(key, ttl=nil, options=nil) options = options.nil? ? CACHE_NILS : options.merge(CACHE_NILS) if @options[:cache_nils] val = get(key, options) not_found = @options[:cache_nils] ? val == Dalli::Server::NOT_FOUND : val.nil? if not_found && block_given? val = yield ...
[ "def", "fetch", "(", "key", ",", "ttl", "=", "nil", ",", "options", "=", "nil", ")", "options", "=", "options", ".", "nil?", "?", "CACHE_NILS", ":", "options", ".", "merge", "(", "CACHE_NILS", ")", "if", "@options", "[", ":cache_nils", "]", "val", "=...
Fetch the value associated with the key. If a value is found, then it is returned. If a value is not found and no block is given, then nil is returned. If a value is not found (or if the found value is nil and :cache_nils is false) and a block is given, the block will be invoked and its return value written to t...
[ "Fetch", "the", "value", "associated", "with", "the", "key", ".", "If", "a", "value", "is", "found", "then", "it", "is", "returned", "." ]
5755dbfd06e333a8239f976d4b10492b4555b726
https://github.com/petergoldstein/dalli/blob/5755dbfd06e333a8239f976d4b10492b4555b726/lib/dalli/client.rb#L90-L101
train
petergoldstein/dalli
lib/dalli/client.rb
Dalli.Client.cas
def cas(key, ttl=nil, options=nil, &block) cas_core(key, false, ttl, options, &block) end
ruby
def cas(key, ttl=nil, options=nil, &block) cas_core(key, false, ttl, options, &block) end
[ "def", "cas", "(", "key", ",", "ttl", "=", "nil", ",", "options", "=", "nil", ",", "&", "block", ")", "cas_core", "(", "key", ",", "false", ",", "ttl", ",", "options", ",", "block", ")", "end" ]
compare and swap values using optimistic locking. Fetch the existing value for key. If it exists, yield the value to the block. Add the block's return value as the new value for the key. Add will fail if someone else changed the value. Returns: - nil if the key did not exist. - false if the value was changed by...
[ "compare", "and", "swap", "values", "using", "optimistic", "locking", ".", "Fetch", "the", "existing", "value", "for", "key", ".", "If", "it", "exists", "yield", "the", "value", "to", "the", "block", ".", "Add", "the", "block", "s", "return", "value", "a...
5755dbfd06e333a8239f976d4b10492b4555b726
https://github.com/petergoldstein/dalli/blob/5755dbfd06e333a8239f976d4b10492b4555b726/lib/dalli/client.rb#L114-L116
train
petergoldstein/dalli
lib/dalli/client.rb
Dalli.Client.incr
def incr(key, amt=1, ttl=nil, default=nil) raise ArgumentError, "Positive values only: #{amt}" if amt < 0 perform(:incr, key, amt.to_i, ttl_or_default(ttl), default) end
ruby
def incr(key, amt=1, ttl=nil, default=nil) raise ArgumentError, "Positive values only: #{amt}" if amt < 0 perform(:incr, key, amt.to_i, ttl_or_default(ttl), default) end
[ "def", "incr", "(", "key", ",", "amt", "=", "1", ",", "ttl", "=", "nil", ",", "default", "=", "nil", ")", "raise", "ArgumentError", ",", "\"Positive values only: #{amt}\"", "if", "amt", "<", "0", "perform", "(", ":incr", ",", "key", ",", "amt", ".", ...
Incr adds the given amount to the counter on the memcached server. Amt must be a positive integer value. If default is nil, the counter must already exist or the operation will fail and will return nil. Otherwise this method will return the new value for the counter. Note that the ttl will only apply if the cou...
[ "Incr", "adds", "the", "given", "amount", "to", "the", "counter", "on", "the", "memcached", "server", ".", "Amt", "must", "be", "a", "positive", "integer", "value", "." ]
5755dbfd06e333a8239f976d4b10492b4555b726
https://github.com/petergoldstein/dalli/blob/5755dbfd06e333a8239f976d4b10492b4555b726/lib/dalli/client.rb#L183-L186
train
petergoldstein/dalli
lib/dalli/client.rb
Dalli.Client.touch
def touch(key, ttl=nil) resp = perform(:touch, key, ttl_or_default(ttl)) resp.nil? ? nil : true end
ruby
def touch(key, ttl=nil) resp = perform(:touch, key, ttl_or_default(ttl)) resp.nil? ? nil : true end
[ "def", "touch", "(", "key", ",", "ttl", "=", "nil", ")", "resp", "=", "perform", "(", ":touch", ",", "key", ",", "ttl_or_default", "(", "ttl", ")", ")", "resp", ".", "nil?", "?", "nil", ":", "true", "end" ]
Touch updates expiration time for a given key. Returns true if key exists, otherwise nil.
[ "Touch", "updates", "expiration", "time", "for", "a", "given", "key", "." ]
5755dbfd06e333a8239f976d4b10492b4555b726
https://github.com/petergoldstein/dalli/blob/5755dbfd06e333a8239f976d4b10492b4555b726/lib/dalli/client.rb#L211-L214
train
petergoldstein/dalli
lib/dalli/client.rb
Dalli.Client.version
def version values = {} ring.servers.each do |server| values["#{server.name}"] = server.alive? ? server.request(:version) : nil end values end
ruby
def version values = {} ring.servers.each do |server| values["#{server.name}"] = server.alive? ? server.request(:version) : nil end values end
[ "def", "version", "values", "=", "{", "}", "ring", ".", "servers", ".", "each", "do", "|", "server", "|", "values", "[", "\"#{server.name}\"", "]", "=", "server", ".", "alive?", "?", "server", ".", "request", "(", ":version", ")", ":", "nil", "end", ...
Version of the memcache servers.
[ "Version", "of", "the", "memcache", "servers", "." ]
5755dbfd06e333a8239f976d4b10492b4555b726
https://github.com/petergoldstein/dalli/blob/5755dbfd06e333a8239f976d4b10492b4555b726/lib/dalli/client.rb#L245-L251
train
petergoldstein/dalli
lib/dalli/client.rb
Dalli.Client.get_multi_yielder
def get_multi_yielder(keys) perform do return {} if keys.empty? ring.lock do begin groups = groups_for_keys(keys) if unfound_keys = groups.delete(nil) Dalli.logger.debug { "unable to get keys for #{unfound_keys.length} keys because no matching server...
ruby
def get_multi_yielder(keys) perform do return {} if keys.empty? ring.lock do begin groups = groups_for_keys(keys) if unfound_keys = groups.delete(nil) Dalli.logger.debug { "unable to get keys for #{unfound_keys.length} keys because no matching server...
[ "def", "get_multi_yielder", "(", "keys", ")", "perform", "do", "return", "{", "}", "if", "keys", ".", "empty?", "ring", ".", "lock", "do", "begin", "groups", "=", "groups_for_keys", "(", "keys", ")", "if", "unfound_keys", "=", "groups", ".", "delete", "(...
Yields, one at a time, keys and their values+attributes.
[ "Yields", "one", "at", "a", "time", "keys", "and", "their", "values", "+", "attributes", "." ]
5755dbfd06e333a8239f976d4b10492b4555b726
https://github.com/petergoldstein/dalli/blob/5755dbfd06e333a8239f976d4b10492b4555b726/lib/dalli/client.rb#L415-L473
train
abonas/kubeclient
lib/kubeclient/common.rb
Kubeclient.ClientMixin.delete_entity
def delete_entity(resource_name, name, namespace = nil, delete_options: {}) delete_options_hash = delete_options.to_hash ns_prefix = build_namespace_prefix(namespace) payload = delete_options_hash.to_json unless delete_options_hash.empty? response = handle_exception do rs = rest_client[n...
ruby
def delete_entity(resource_name, name, namespace = nil, delete_options: {}) delete_options_hash = delete_options.to_hash ns_prefix = build_namespace_prefix(namespace) payload = delete_options_hash.to_json unless delete_options_hash.empty? response = handle_exception do rs = rest_client[n...
[ "def", "delete_entity", "(", "resource_name", ",", "name", ",", "namespace", "=", "nil", ",", "delete_options", ":", "{", "}", ")", "delete_options_hash", "=", "delete_options", ".", "to_hash", "ns_prefix", "=", "build_namespace_prefix", "(", "namespace", ")", "...
delete_options are passed as a JSON payload in the delete request
[ "delete_options", "are", "passed", "as", "a", "JSON", "payload", "in", "the", "delete", "request" ]
3630f6c82532fba04f3e1a62d6b99c6cf2910451
https://github.com/abonas/kubeclient/blob/3630f6c82532fba04f3e1a62d6b99c6cf2910451/lib/kubeclient/common.rb#L350-L366
train
abonas/kubeclient
lib/kubeclient/common.rb
Kubeclient.ClientMixin.format_datetime
def format_datetime(value) case value when DateTime, Time value.strftime('%FT%T.%9N%:z') when String value else raise ArgumentError, "unsupported type '#{value.class}' of time value '#{value}'" end end
ruby
def format_datetime(value) case value when DateTime, Time value.strftime('%FT%T.%9N%:z') when String value else raise ArgumentError, "unsupported type '#{value.class}' of time value '#{value}'" end end
[ "def", "format_datetime", "(", "value", ")", "case", "value", "when", "DateTime", ",", "Time", "value", ".", "strftime", "(", "'%FT%T.%9N%:z'", ")", "when", "String", "value", "else", "raise", "ArgumentError", ",", "\"unsupported type '#{value.class}' of time value '#...
Format datetime according to RFC3339
[ "Format", "datetime", "according", "to", "RFC3339" ]
3630f6c82532fba04f3e1a62d6b99c6cf2910451
https://github.com/abonas/kubeclient/blob/3630f6c82532fba04f3e1a62d6b99c6cf2910451/lib/kubeclient/common.rb#L499-L508
train
sporkmonger/addressable
lib/addressable/template.rb
Addressable.Template.extract
def extract(uri, processor=nil) match_data = self.match(uri, processor) return (match_data ? match_data.mapping : nil) end
ruby
def extract(uri, processor=nil) match_data = self.match(uri, processor) return (match_data ? match_data.mapping : nil) end
[ "def", "extract", "(", "uri", ",", "processor", "=", "nil", ")", "match_data", "=", "self", ".", "match", "(", "uri", ",", "processor", ")", "return", "(", "match_data", "?", "match_data", ".", "mapping", ":", "nil", ")", "end" ]
Extracts a mapping from the URI using a URI Template pattern. @param [Addressable::URI, #to_str] uri The URI to extract from. @param [#restore, #match] processor A template processor object may optionally be supplied. The object should respond to either the <tt>restore</tt> or <tt>match</tt> messages o...
[ "Extracts", "a", "mapping", "from", "the", "URI", "using", "a", "URI", "Template", "pattern", "." ]
5894c95a7768435cb46d1355954611dbd194832e
https://github.com/sporkmonger/addressable/blob/5894c95a7768435cb46d1355954611dbd194832e/lib/addressable/template.rb#L343-L346
train
sporkmonger/addressable
lib/addressable/template.rb
Addressable.Template.match
def match(uri, processor=nil) uri = Addressable::URI.parse(uri) mapping = {} # First, we need to process the pattern, and extract the values. expansions, expansion_regexp = parse_template_pattern(pattern, processor) return nil unless uri.to_str.match(expansion_regexp) unpar...
ruby
def match(uri, processor=nil) uri = Addressable::URI.parse(uri) mapping = {} # First, we need to process the pattern, and extract the values. expansions, expansion_regexp = parse_template_pattern(pattern, processor) return nil unless uri.to_str.match(expansion_regexp) unpar...
[ "def", "match", "(", "uri", ",", "processor", "=", "nil", ")", "uri", "=", "Addressable", "::", "URI", ".", "parse", "(", "uri", ")", "mapping", "=", "{", "}", "# First, we need to process the pattern, and extract the values.", "expansions", ",", "expansion_regexp...
Extracts match data from the URI using a URI Template pattern. @param [Addressable::URI, #to_str] uri The URI to extract from. @param [#restore, #match] processor A template processor object may optionally be supplied. The object should respond to either the <tt>restore</tt> or <tt>match</tt> messages ...
[ "Extracts", "match", "data", "from", "the", "URI", "using", "a", "URI", "Template", "pattern", "." ]
5894c95a7768435cb46d1355954611dbd194832e
https://github.com/sporkmonger/addressable/blob/5894c95a7768435cb46d1355954611dbd194832e/lib/addressable/template.rb#L414-L485
train
sporkmonger/addressable
lib/addressable/template.rb
Addressable.Template.partial_expand
def partial_expand(mapping, processor=nil, normalize_values=true) result = self.pattern.dup mapping = normalize_keys(mapping) result.gsub!( EXPRESSION ) do |capture| transform_partial_capture(mapping, capture, processor, normalize_values) end return Addressable::Template.new(result...
ruby
def partial_expand(mapping, processor=nil, normalize_values=true) result = self.pattern.dup mapping = normalize_keys(mapping) result.gsub!( EXPRESSION ) do |capture| transform_partial_capture(mapping, capture, processor, normalize_values) end return Addressable::Template.new(result...
[ "def", "partial_expand", "(", "mapping", ",", "processor", "=", "nil", ",", "normalize_values", "=", "true", ")", "result", "=", "self", ".", "pattern", ".", "dup", "mapping", "=", "normalize_keys", "(", "mapping", ")", "result", ".", "gsub!", "(", "EXPRES...
Expands a URI template into another URI template. @param [Hash] mapping The mapping that corresponds to the pattern. @param [#validate, #transform] processor An optional processor object may be supplied. @param [Boolean] normalize_values Optional flag to enable/disable unicode normalization. Default: true T...
[ "Expands", "a", "URI", "template", "into", "another", "URI", "template", "." ]
5894c95a7768435cb46d1355954611dbd194832e
https://github.com/sporkmonger/addressable/blob/5894c95a7768435cb46d1355954611dbd194832e/lib/addressable/template.rb#L525-L532
train
sporkmonger/addressable
lib/addressable/template.rb
Addressable.Template.expand
def expand(mapping, processor=nil, normalize_values=true) result = self.pattern.dup mapping = normalize_keys(mapping) result.gsub!( EXPRESSION ) do |capture| transform_capture(mapping, capture, processor, normalize_values) end return Addressable::URI.parse(result) end
ruby
def expand(mapping, processor=nil, normalize_values=true) result = self.pattern.dup mapping = normalize_keys(mapping) result.gsub!( EXPRESSION ) do |capture| transform_capture(mapping, capture, processor, normalize_values) end return Addressable::URI.parse(result) end
[ "def", "expand", "(", "mapping", ",", "processor", "=", "nil", ",", "normalize_values", "=", "true", ")", "result", "=", "self", ".", "pattern", ".", "dup", "mapping", "=", "normalize_keys", "(", "mapping", ")", "result", ".", "gsub!", "(", "EXPRESSION", ...
Expands a URI template into a full URI. @param [Hash] mapping The mapping that corresponds to the pattern. @param [#validate, #transform] processor An optional processor object may be supplied. @param [Boolean] normalize_values Optional flag to enable/disable unicode normalization. Default: true The object ...
[ "Expands", "a", "URI", "template", "into", "a", "full", "URI", "." ]
5894c95a7768435cb46d1355954611dbd194832e
https://github.com/sporkmonger/addressable/blob/5894c95a7768435cb46d1355954611dbd194832e/lib/addressable/template.rb#L592-L599
train
sporkmonger/addressable
lib/addressable/template.rb
Addressable.Template.generate
def generate(params={}, recall={}, options={}) merged = recall.merge(params) if options[:processor] processor = options[:processor] elsif options[:parameterize] # TODO: This is sending me into fits trying to shoe-horn this into # the existing API. I think I've got this backward...
ruby
def generate(params={}, recall={}, options={}) merged = recall.merge(params) if options[:processor] processor = options[:processor] elsif options[:parameterize] # TODO: This is sending me into fits trying to shoe-horn this into # the existing API. I think I've got this backward...
[ "def", "generate", "(", "params", "=", "{", "}", ",", "recall", "=", "{", "}", ",", "options", "=", "{", "}", ")", "merged", "=", "recall", ".", "merge", "(", "params", ")", "if", "options", "[", ":processor", "]", "processor", "=", "options", "[",...
Generates a route result for a given set of parameters. Should only be used by rack-mount. @param params [Hash] The set of parameters used to expand the template. @param recall [Hash] Default parameters used to expand the template. @param options [Hash] Either a `:processor` or a `:parameterize` block. @api priv...
[ "Generates", "a", "route", "result", "for", "a", "given", "set", "of", "parameters", ".", "Should", "only", "be", "used", "by", "rack", "-", "mount", "." ]
5894c95a7768435cb46d1355954611dbd194832e
https://github.com/sporkmonger/addressable/blob/5894c95a7768435cb46d1355954611dbd194832e/lib/addressable/template.rb#L665-L688
train
sporkmonger/addressable
lib/addressable/template.rb
Addressable.Template.transform_partial_capture
def transform_partial_capture(mapping, capture, processor = nil, normalize_values = true) _, operator, varlist = *capture.match(EXPRESSION) vars = varlist.split(",") if operator == "?" # partial expansion of form style query variables sometimes requires a ...
ruby
def transform_partial_capture(mapping, capture, processor = nil, normalize_values = true) _, operator, varlist = *capture.match(EXPRESSION) vars = varlist.split(",") if operator == "?" # partial expansion of form style query variables sometimes requires a ...
[ "def", "transform_partial_capture", "(", "mapping", ",", "capture", ",", "processor", "=", "nil", ",", "normalize_values", "=", "true", ")", "_", ",", "operator", ",", "varlist", "=", "capture", ".", "match", "(", "EXPRESSION", ")", "vars", "=", "varlist", ...
Loops through each capture and expands any values available in mapping @param [Hash] mapping Set of keys to expand @param [String] capture The expression to expand @param [#validate, #transform] processor An optional processor object may be supplied. @param [Boolean] normalize_values Optional flag to e...
[ "Loops", "through", "each", "capture", "and", "expands", "any", "values", "available", "in", "mapping" ]
5894c95a7768435cb46d1355954611dbd194832e
https://github.com/sporkmonger/addressable/blob/5894c95a7768435cb46d1355954611dbd194832e/lib/addressable/template.rb#L729-L760
train
sporkmonger/addressable
lib/addressable/template.rb
Addressable.Template.normalize_keys
def normalize_keys(mapping) return mapping.inject({}) do |accu, pair| name, value = pair if Symbol === name name = name.to_s elsif name.respond_to?(:to_str) name = name.to_str else raise TypeError, "Can't convert #{name.class} into String."...
ruby
def normalize_keys(mapping) return mapping.inject({}) do |accu, pair| name, value = pair if Symbol === name name = name.to_s elsif name.respond_to?(:to_str) name = name.to_str else raise TypeError, "Can't convert #{name.class} into String."...
[ "def", "normalize_keys", "(", "mapping", ")", "return", "mapping", ".", "inject", "(", "{", "}", ")", "do", "|", "accu", ",", "pair", "|", "name", ",", "value", "=", "pair", "if", "Symbol", "===", "name", "name", "=", "name", ".", "to_s", "elsif", ...
Generates a hash with string keys @param [Hash] mapping A mapping hash to normalize @return [Hash] A hash with stringified keys
[ "Generates", "a", "hash", "with", "string", "keys" ]
5894c95a7768435cb46d1355954611dbd194832e
https://github.com/sporkmonger/addressable/blob/5894c95a7768435cb46d1355954611dbd194832e/lib/addressable/template.rb#L960-L974
train
sporkmonger/addressable
lib/addressable/uri.rb
Addressable.URI.freeze
def freeze self.normalized_scheme self.normalized_user self.normalized_password self.normalized_userinfo self.normalized_host self.normalized_port self.normalized_authority self.normalized_site self.normalized_path self.normalized_query self.normalized_f...
ruby
def freeze self.normalized_scheme self.normalized_user self.normalized_password self.normalized_userinfo self.normalized_host self.normalized_port self.normalized_authority self.normalized_site self.normalized_path self.normalized_query self.normalized_f...
[ "def", "freeze", "self", ".", "normalized_scheme", "self", ".", "normalized_user", "self", ".", "normalized_password", "self", ".", "normalized_userinfo", "self", ".", "normalized_host", "self", ".", "normalized_port", "self", ".", "normalized_authority", "self", ".",...
Creates a new uri object from component parts. @option [String, #to_str] scheme The scheme component. @option [String, #to_str] user The user component. @option [String, #to_str] password The password component. @option [String, #to_str] userinfo The userinfo component. If this is supplied, the user and passwor...
[ "Creates", "a", "new", "uri", "object", "from", "component", "parts", "." ]
5894c95a7768435cb46d1355954611dbd194832e
https://github.com/sporkmonger/addressable/blob/5894c95a7768435cb46d1355954611dbd194832e/lib/addressable/uri.rb#L827-L841
train
sporkmonger/addressable
lib/addressable/uri.rb
Addressable.URI.normalized_scheme
def normalized_scheme return nil unless self.scheme @normalized_scheme ||= begin if self.scheme =~ /^\s*ssh\+svn\s*$/i "svn+ssh".dup else Addressable::URI.normalize_component( self.scheme.strip.downcase, Addressable::URI::CharacterClasses::SCHEME ...
ruby
def normalized_scheme return nil unless self.scheme @normalized_scheme ||= begin if self.scheme =~ /^\s*ssh\+svn\s*$/i "svn+ssh".dup else Addressable::URI.normalize_component( self.scheme.strip.downcase, Addressable::URI::CharacterClasses::SCHEME ...
[ "def", "normalized_scheme", "return", "nil", "unless", "self", ".", "scheme", "@normalized_scheme", "||=", "begin", "if", "self", ".", "scheme", "=~", "/", "\\s", "\\+", "\\s", "/i", "\"svn+ssh\"", ".", "dup", "else", "Addressable", "::", "URI", ".", "normal...
The scheme component for this URI, normalized. @return [String] The scheme component, normalized.
[ "The", "scheme", "component", "for", "this", "URI", "normalized", "." ]
5894c95a7768435cb46d1355954611dbd194832e
https://github.com/sporkmonger/addressable/blob/5894c95a7768435cb46d1355954611dbd194832e/lib/addressable/uri.rb#L855-L870
train
sporkmonger/addressable
lib/addressable/uri.rb
Addressable.URI.scheme=
def scheme=(new_scheme) if new_scheme && !new_scheme.respond_to?(:to_str) raise TypeError, "Can't convert #{new_scheme.class} into String." elsif new_scheme new_scheme = new_scheme.to_str end if new_scheme && new_scheme !~ /\A[a-z][a-z0-9\.\+\-]*\z/i raise InvalidURIError...
ruby
def scheme=(new_scheme) if new_scheme && !new_scheme.respond_to?(:to_str) raise TypeError, "Can't convert #{new_scheme.class} into String." elsif new_scheme new_scheme = new_scheme.to_str end if new_scheme && new_scheme !~ /\A[a-z][a-z0-9\.\+\-]*\z/i raise InvalidURIError...
[ "def", "scheme", "=", "(", "new_scheme", ")", "if", "new_scheme", "&&", "!", "new_scheme", ".", "respond_to?", "(", ":to_str", ")", "raise", "TypeError", ",", "\"Can't convert #{new_scheme.class} into String.\"", "elsif", "new_scheme", "new_scheme", "=", "new_scheme",...
Sets the scheme component for this URI. @param [String, #to_str] new_scheme The new scheme component.
[ "Sets", "the", "scheme", "component", "for", "this", "URI", "." ]
5894c95a7768435cb46d1355954611dbd194832e
https://github.com/sporkmonger/addressable/blob/5894c95a7768435cb46d1355954611dbd194832e/lib/addressable/uri.rb#L876-L894
train
sporkmonger/addressable
lib/addressable/uri.rb
Addressable.URI.user=
def user=(new_user) if new_user && !new_user.respond_to?(:to_str) raise TypeError, "Can't convert #{new_user.class} into String." end @user = new_user ? new_user.to_str : nil # You can't have a nil user with a non-nil password if password != nil @user = EMPTY_STR if @user....
ruby
def user=(new_user) if new_user && !new_user.respond_to?(:to_str) raise TypeError, "Can't convert #{new_user.class} into String." end @user = new_user ? new_user.to_str : nil # You can't have a nil user with a non-nil password if password != nil @user = EMPTY_STR if @user....
[ "def", "user", "=", "(", "new_user", ")", "if", "new_user", "&&", "!", "new_user", ".", "respond_to?", "(", ":to_str", ")", "raise", "TypeError", ",", "\"Can't convert #{new_user.class} into String.\"", "end", "@user", "=", "new_user", "?", "new_user", ".", "to_...
Sets the user component for this URI. @param [String, #to_str] new_user The new user component.
[ "Sets", "the", "user", "component", "for", "this", "URI", "." ]
5894c95a7768435cb46d1355954611dbd194832e
https://github.com/sporkmonger/addressable/blob/5894c95a7768435cb46d1355954611dbd194832e/lib/addressable/uri.rb#L931-L951
train
sporkmonger/addressable
lib/addressable/uri.rb
Addressable.URI.normalized_password
def normalized_password return nil unless self.password return @normalized_password if defined?(@normalized_password) @normalized_password ||= begin if self.normalized_scheme =~ /https?/ && self.password.strip.empty? && (!self.user || self.user.strip.empty?) nil e...
ruby
def normalized_password return nil unless self.password return @normalized_password if defined?(@normalized_password) @normalized_password ||= begin if self.normalized_scheme =~ /https?/ && self.password.strip.empty? && (!self.user || self.user.strip.empty?) nil e...
[ "def", "normalized_password", "return", "nil", "unless", "self", ".", "password", "return", "@normalized_password", "if", "defined?", "(", "@normalized_password", ")", "@normalized_password", "||=", "begin", "if", "self", ".", "normalized_scheme", "=~", "/", "/", "&...
The password component for this URI, normalized. @return [String] The password component, normalized.
[ "The", "password", "component", "for", "this", "URI", "normalized", "." ]
5894c95a7768435cb46d1355954611dbd194832e
https://github.com/sporkmonger/addressable/blob/5894c95a7768435cb46d1355954611dbd194832e/lib/addressable/uri.rb#L965-L984
train
sporkmonger/addressable
lib/addressable/uri.rb
Addressable.URI.password=
def password=(new_password) if new_password && !new_password.respond_to?(:to_str) raise TypeError, "Can't convert #{new_password.class} into String." end @password = new_password ? new_password.to_str : nil # You can't have a nil user with a non-nil password @password ||= nil ...
ruby
def password=(new_password) if new_password && !new_password.respond_to?(:to_str) raise TypeError, "Can't convert #{new_password.class} into String." end @password = new_password ? new_password.to_str : nil # You can't have a nil user with a non-nil password @password ||= nil ...
[ "def", "password", "=", "(", "new_password", ")", "if", "new_password", "&&", "!", "new_password", ".", "respond_to?", "(", ":to_str", ")", "raise", "TypeError", ",", "\"Can't convert #{new_password.class} into String.\"", "end", "@password", "=", "new_password", "?",...
Sets the password component for this URI. @param [String, #to_str] new_password The new password component.
[ "Sets", "the", "password", "component", "for", "this", "URI", "." ]
5894c95a7768435cb46d1355954611dbd194832e
https://github.com/sporkmonger/addressable/blob/5894c95a7768435cb46d1355954611dbd194832e/lib/addressable/uri.rb#L990-L1012
train
sporkmonger/addressable
lib/addressable/uri.rb
Addressable.URI.userinfo
def userinfo current_user = self.user current_password = self.password (current_user || current_password) && @userinfo ||= begin if current_user && current_password "#{current_user}:#{current_password}" elsif current_user && !current_password "#{current_user}" ...
ruby
def userinfo current_user = self.user current_password = self.password (current_user || current_password) && @userinfo ||= begin if current_user && current_password "#{current_user}:#{current_password}" elsif current_user && !current_password "#{current_user}" ...
[ "def", "userinfo", "current_user", "=", "self", ".", "user", "current_password", "=", "self", ".", "password", "(", "current_user", "||", "current_password", ")", "&&", "@userinfo", "||=", "begin", "if", "current_user", "&&", "current_password", "\"#{current_user}:#...
The userinfo component for this URI. Combines the user and password components. @return [String] The userinfo component.
[ "The", "userinfo", "component", "for", "this", "URI", ".", "Combines", "the", "user", "and", "password", "components", "." ]
5894c95a7768435cb46d1355954611dbd194832e
https://github.com/sporkmonger/addressable/blob/5894c95a7768435cb46d1355954611dbd194832e/lib/addressable/uri.rb#L1019-L1029
train
sporkmonger/addressable
lib/addressable/uri.rb
Addressable.URI.normalized_userinfo
def normalized_userinfo return nil unless self.userinfo return @normalized_userinfo if defined?(@normalized_userinfo) @normalized_userinfo ||= begin current_user = self.normalized_user current_password = self.normalized_password if !current_user && !current_password n...
ruby
def normalized_userinfo return nil unless self.userinfo return @normalized_userinfo if defined?(@normalized_userinfo) @normalized_userinfo ||= begin current_user = self.normalized_user current_password = self.normalized_password if !current_user && !current_password n...
[ "def", "normalized_userinfo", "return", "nil", "unless", "self", ".", "userinfo", "return", "@normalized_userinfo", "if", "defined?", "(", "@normalized_userinfo", ")", "@normalized_userinfo", "||=", "begin", "current_user", "=", "self", ".", "normalized_user", "current_...
The userinfo component for this URI, normalized. @return [String] The userinfo component, normalized.
[ "The", "userinfo", "component", "for", "this", "URI", "normalized", "." ]
5894c95a7768435cb46d1355954611dbd194832e
https://github.com/sporkmonger/addressable/blob/5894c95a7768435cb46d1355954611dbd194832e/lib/addressable/uri.rb#L1035-L1054
train
sporkmonger/addressable
lib/addressable/uri.rb
Addressable.URI.userinfo=
def userinfo=(new_userinfo) if new_userinfo && !new_userinfo.respond_to?(:to_str) raise TypeError, "Can't convert #{new_userinfo.class} into String." end new_user, new_password = if new_userinfo [ new_userinfo.to_str.strip[/^(.*):/, 1], new_userinfo.to_str.strip[/:(...
ruby
def userinfo=(new_userinfo) if new_userinfo && !new_userinfo.respond_to?(:to_str) raise TypeError, "Can't convert #{new_userinfo.class} into String." end new_user, new_password = if new_userinfo [ new_userinfo.to_str.strip[/^(.*):/, 1], new_userinfo.to_str.strip[/:(...
[ "def", "userinfo", "=", "(", "new_userinfo", ")", "if", "new_userinfo", "&&", "!", "new_userinfo", ".", "respond_to?", "(", ":to_str", ")", "raise", "TypeError", ",", "\"Can't convert #{new_userinfo.class} into String.\"", "end", "new_user", ",", "new_password", "=", ...
Sets the userinfo component for this URI. @param [String, #to_str] new_userinfo The new userinfo component.
[ "Sets", "the", "userinfo", "component", "for", "this", "URI", "." ]
5894c95a7768435cb46d1355954611dbd194832e
https://github.com/sporkmonger/addressable/blob/5894c95a7768435cb46d1355954611dbd194832e/lib/addressable/uri.rb#L1060-L1083
train
sporkmonger/addressable
lib/addressable/uri.rb
Addressable.URI.normalized_host
def normalized_host return nil unless self.host @normalized_host ||= begin if !self.host.strip.empty? result = ::Addressable::IDNA.to_ascii( URI.unencode_component(self.host.strip.downcase) ) if result =~ /[^\.]\.$/ # Single trailing dots are unn...
ruby
def normalized_host return nil unless self.host @normalized_host ||= begin if !self.host.strip.empty? result = ::Addressable::IDNA.to_ascii( URI.unencode_component(self.host.strip.downcase) ) if result =~ /[^\.]\.$/ # Single trailing dots are unn...
[ "def", "normalized_host", "return", "nil", "unless", "self", ".", "host", "@normalized_host", "||=", "begin", "if", "!", "self", ".", "host", ".", "strip", ".", "empty?", "result", "=", "::", "Addressable", "::", "IDNA", ".", "to_ascii", "(", "URI", ".", ...
The host component for this URI, normalized. @return [String] The host component, normalized.
[ "The", "host", "component", "for", "this", "URI", "normalized", "." ]
5894c95a7768435cb46d1355954611dbd194832e
https://github.com/sporkmonger/addressable/blob/5894c95a7768435cb46d1355954611dbd194832e/lib/addressable/uri.rb#L1097-L1119
train
sporkmonger/addressable
lib/addressable/uri.rb
Addressable.URI.host=
def host=(new_host) if new_host && !new_host.respond_to?(:to_str) raise TypeError, "Can't convert #{new_host.class} into String." end @host = new_host ? new_host.to_str : nil # Reset dependent values remove_instance_variable(:@authority) if defined?(@authority) remove_instan...
ruby
def host=(new_host) if new_host && !new_host.respond_to?(:to_str) raise TypeError, "Can't convert #{new_host.class} into String." end @host = new_host ? new_host.to_str : nil # Reset dependent values remove_instance_variable(:@authority) if defined?(@authority) remove_instan...
[ "def", "host", "=", "(", "new_host", ")", "if", "new_host", "&&", "!", "new_host", ".", "respond_to?", "(", ":to_str", ")", "raise", "TypeError", ",", "\"Can't convert #{new_host.class} into String.\"", "end", "@host", "=", "new_host", "?", "new_host", ".", "to_...
Sets the host component for this URI. @param [String, #to_str] new_host The new host component.
[ "Sets", "the", "host", "component", "for", "this", "URI", "." ]
5894c95a7768435cb46d1355954611dbd194832e
https://github.com/sporkmonger/addressable/blob/5894c95a7768435cb46d1355954611dbd194832e/lib/addressable/uri.rb#L1125-L1138
train
sporkmonger/addressable
lib/addressable/uri.rb
Addressable.URI.authority
def authority self.host && @authority ||= begin authority = String.new if self.userinfo != nil authority << "#{self.userinfo}@" end authority << self.host if self.port != nil authority << ":#{self.port}" end authority end end
ruby
def authority self.host && @authority ||= begin authority = String.new if self.userinfo != nil authority << "#{self.userinfo}@" end authority << self.host if self.port != nil authority << ":#{self.port}" end authority end end
[ "def", "authority", "self", ".", "host", "&&", "@authority", "||=", "begin", "authority", "=", "String", ".", "new", "if", "self", ".", "userinfo", "!=", "nil", "authority", "<<", "\"#{self.userinfo}@\"", "end", "authority", "<<", "self", ".", "host", "if", ...
The authority component for this URI. Combines the user, password, host, and port components. @return [String] The authority component.
[ "The", "authority", "component", "for", "this", "URI", ".", "Combines", "the", "user", "password", "host", "and", "port", "components", "." ]
5894c95a7768435cb46d1355954611dbd194832e
https://github.com/sporkmonger/addressable/blob/5894c95a7768435cb46d1355954611dbd194832e/lib/addressable/uri.rb#L1203-L1215
train
sporkmonger/addressable
lib/addressable/uri.rb
Addressable.URI.normalized_authority
def normalized_authority return nil unless self.authority @normalized_authority ||= begin authority = String.new if self.normalized_userinfo != nil authority << "#{self.normalized_userinfo}@" end authority << self.normalized_host if self.normalized_port != n...
ruby
def normalized_authority return nil unless self.authority @normalized_authority ||= begin authority = String.new if self.normalized_userinfo != nil authority << "#{self.normalized_userinfo}@" end authority << self.normalized_host if self.normalized_port != n...
[ "def", "normalized_authority", "return", "nil", "unless", "self", ".", "authority", "@normalized_authority", "||=", "begin", "authority", "=", "String", ".", "new", "if", "self", ".", "normalized_userinfo", "!=", "nil", "authority", "<<", "\"#{self.normalized_userinfo...
The authority component for this URI, normalized. @return [String] The authority component, normalized.
[ "The", "authority", "component", "for", "this", "URI", "normalized", "." ]
5894c95a7768435cb46d1355954611dbd194832e
https://github.com/sporkmonger/addressable/blob/5894c95a7768435cb46d1355954611dbd194832e/lib/addressable/uri.rb#L1221-L1239
train
sporkmonger/addressable
lib/addressable/uri.rb
Addressable.URI.authority=
def authority=(new_authority) if new_authority if !new_authority.respond_to?(:to_str) raise TypeError, "Can't convert #{new_authority.class} into String." end new_authority = new_authority.to_str new_userinfo = new_authority[/^([^\[\]]*)@/, 1] if new_userinfo ...
ruby
def authority=(new_authority) if new_authority if !new_authority.respond_to?(:to_str) raise TypeError, "Can't convert #{new_authority.class} into String." end new_authority = new_authority.to_str new_userinfo = new_authority[/^([^\[\]]*)@/, 1] if new_userinfo ...
[ "def", "authority", "=", "(", "new_authority", ")", "if", "new_authority", "if", "!", "new_authority", ".", "respond_to?", "(", ":to_str", ")", "raise", "TypeError", ",", "\"Can't convert #{new_authority.class} into String.\"", "end", "new_authority", "=", "new_authorit...
Sets the authority component for this URI. @param [String, #to_str] new_authority The new authority component.
[ "Sets", "the", "authority", "component", "for", "this", "URI", "." ]
5894c95a7768435cb46d1355954611dbd194832e
https://github.com/sporkmonger/addressable/blob/5894c95a7768435cb46d1355954611dbd194832e/lib/addressable/uri.rb#L1245-L1278
train
sporkmonger/addressable
lib/addressable/uri.rb
Addressable.URI.origin=
def origin=(new_origin) if new_origin if !new_origin.respond_to?(:to_str) raise TypeError, "Can't convert #{new_origin.class} into String." end new_origin = new_origin.to_str new_scheme = new_origin[/^([^:\/?#]+):\/\//, 1] unless new_scheme raise Invalid...
ruby
def origin=(new_origin) if new_origin if !new_origin.respond_to?(:to_str) raise TypeError, "Can't convert #{new_origin.class} into String." end new_origin = new_origin.to_str new_scheme = new_origin[/^([^:\/?#]+):\/\//, 1] unless new_scheme raise Invalid...
[ "def", "origin", "=", "(", "new_origin", ")", "if", "new_origin", "if", "!", "new_origin", ".", "respond_to?", "(", ":to_str", ")", "raise", "TypeError", ",", "\"Can't convert #{new_origin.class} into String.\"", "end", "new_origin", "=", "new_origin", ".", "to_str"...
Sets the origin for this URI, serialized to ASCII, as per RFC 6454, section 6.2. This assignment will reset the `userinfo` component. @param [String, #to_str] new_origin The new origin component.
[ "Sets", "the", "origin", "for", "this", "URI", "serialized", "to", "ASCII", "as", "per", "RFC", "6454", "section", "6", ".", "2", ".", "This", "assignment", "will", "reset", "the", "userinfo", "component", "." ]
5894c95a7768435cb46d1355954611dbd194832e
https://github.com/sporkmonger/addressable/blob/5894c95a7768435cb46d1355954611dbd194832e/lib/addressable/uri.rb#L1304-L1335
train
sporkmonger/addressable
lib/addressable/uri.rb
Addressable.URI.port=
def port=(new_port) if new_port != nil && new_port.respond_to?(:to_str) new_port = Addressable::URI.unencode_component(new_port.to_str) end if new_port.respond_to?(:valid_encoding?) && !new_port.valid_encoding? raise InvalidURIError, "Invalid encoding in port" end if new_...
ruby
def port=(new_port) if new_port != nil && new_port.respond_to?(:to_str) new_port = Addressable::URI.unencode_component(new_port.to_str) end if new_port.respond_to?(:valid_encoding?) && !new_port.valid_encoding? raise InvalidURIError, "Invalid encoding in port" end if new_...
[ "def", "port", "=", "(", "new_port", ")", "if", "new_port", "!=", "nil", "&&", "new_port", ".", "respond_to?", "(", ":to_str", ")", "new_port", "=", "Addressable", "::", "URI", ".", "unencode_component", "(", "new_port", ".", "to_str", ")", "end", "if", ...
Sets the port component for this URI. @param [String, Integer, #to_s] new_port The new port component.
[ "Sets", "the", "port", "component", "for", "this", "URI", "." ]
5894c95a7768435cb46d1355954611dbd194832e
https://github.com/sporkmonger/addressable/blob/5894c95a7768435cb46d1355954611dbd194832e/lib/addressable/uri.rb#L1381-L1405
train
sporkmonger/addressable
lib/addressable/uri.rb
Addressable.URI.site
def site (self.scheme || self.authority) && @site ||= begin site_string = "".dup site_string << "#{self.scheme}:" if self.scheme != nil site_string << "//#{self.authority}" if self.authority != nil site_string end end
ruby
def site (self.scheme || self.authority) && @site ||= begin site_string = "".dup site_string << "#{self.scheme}:" if self.scheme != nil site_string << "//#{self.authority}" if self.authority != nil site_string end end
[ "def", "site", "(", "self", ".", "scheme", "||", "self", ".", "authority", ")", "&&", "@site", "||=", "begin", "site_string", "=", "\"\"", ".", "dup", "site_string", "<<", "\"#{self.scheme}:\"", "if", "self", ".", "scheme", "!=", "nil", "site_string", "<<"...
The combination of components that represent a site. Combines the scheme, user, password, host, and port components. Primarily useful for HTTP and HTTPS. For example, <code>"http://example.com/path?query"</code> would have a <code>site</code> value of <code>"http://example.com"</code>. @return [String] The compo...
[ "The", "combination", "of", "components", "that", "represent", "a", "site", ".", "Combines", "the", "scheme", "user", "password", "host", "and", "port", "components", ".", "Primarily", "useful", "for", "HTTP", "and", "HTTPS", "." ]
5894c95a7768435cb46d1355954611dbd194832e
https://github.com/sporkmonger/addressable/blob/5894c95a7768435cb46d1355954611dbd194832e/lib/addressable/uri.rb#L1440-L1447
train
sporkmonger/addressable
lib/addressable/uri.rb
Addressable.URI.normalized_site
def normalized_site return nil unless self.site @normalized_site ||= begin site_string = "".dup if self.normalized_scheme != nil site_string << "#{self.normalized_scheme}:" end if self.normalized_authority != nil site_string << "//#{self.normalized_authori...
ruby
def normalized_site return nil unless self.site @normalized_site ||= begin site_string = "".dup if self.normalized_scheme != nil site_string << "#{self.normalized_scheme}:" end if self.normalized_authority != nil site_string << "//#{self.normalized_authori...
[ "def", "normalized_site", "return", "nil", "unless", "self", ".", "site", "@normalized_site", "||=", "begin", "site_string", "=", "\"\"", ".", "dup", "if", "self", ".", "normalized_scheme", "!=", "nil", "site_string", "<<", "\"#{self.normalized_scheme}:\"", "end", ...
The normalized combination of components that represent a site. Combines the scheme, user, password, host, and port components. Primarily useful for HTTP and HTTPS. For example, <code>"http://example.com/path?query"</code> would have a <code>site</code> value of <code>"http://example.com"</code>. @return [String...
[ "The", "normalized", "combination", "of", "components", "that", "represent", "a", "site", ".", "Combines", "the", "scheme", "user", "password", "host", "and", "port", "components", ".", "Primarily", "useful", "for", "HTTP", "and", "HTTPS", "." ]
5894c95a7768435cb46d1355954611dbd194832e
https://github.com/sporkmonger/addressable/blob/5894c95a7768435cb46d1355954611dbd194832e/lib/addressable/uri.rb#L1458-L1473
train
sporkmonger/addressable
lib/addressable/uri.rb
Addressable.URI.site=
def site=(new_site) if new_site if !new_site.respond_to?(:to_str) raise TypeError, "Can't convert #{new_site.class} into String." end new_site = new_site.to_str # These two regular expressions derived from the primary parsing # expression self.scheme = new...
ruby
def site=(new_site) if new_site if !new_site.respond_to?(:to_str) raise TypeError, "Can't convert #{new_site.class} into String." end new_site = new_site.to_str # These two regular expressions derived from the primary parsing # expression self.scheme = new...
[ "def", "site", "=", "(", "new_site", ")", "if", "new_site", "if", "!", "new_site", ".", "respond_to?", "(", ":to_str", ")", "raise", "TypeError", ",", "\"Can't convert #{new_site.class} into String.\"", "end", "new_site", "=", "new_site", ".", "to_str", "# These t...
Sets the site value for this URI. @param [String, #to_str] new_site The new site value.
[ "Sets", "the", "site", "value", "for", "this", "URI", "." ]
5894c95a7768435cb46d1355954611dbd194832e
https://github.com/sporkmonger/addressable/blob/5894c95a7768435cb46d1355954611dbd194832e/lib/addressable/uri.rb#L1479-L1495
train
sporkmonger/addressable
lib/addressable/uri.rb
Addressable.URI.normalized_path
def normalized_path @normalized_path ||= begin path = self.path.to_s if self.scheme == nil && path =~ NORMPATH # Relative paths with colons in the first segment are ambiguous. path = path.sub(":", "%2F") end # String#split(delimeter, -1) uses the more strict spl...
ruby
def normalized_path @normalized_path ||= begin path = self.path.to_s if self.scheme == nil && path =~ NORMPATH # Relative paths with colons in the first segment are ambiguous. path = path.sub(":", "%2F") end # String#split(delimeter, -1) uses the more strict spl...
[ "def", "normalized_path", "@normalized_path", "||=", "begin", "path", "=", "self", ".", "path", ".", "to_s", "if", "self", ".", "scheme", "==", "nil", "&&", "path", "=~", "NORMPATH", "# Relative paths with colons in the first segment are ambiguous.", "path", "=", "p...
The path component for this URI, normalized. @return [String] The path component, normalized.
[ "The", "path", "component", "for", "this", "URI", "normalized", "." ]
5894c95a7768435cb46d1355954611dbd194832e
https://github.com/sporkmonger/addressable/blob/5894c95a7768435cb46d1355954611dbd194832e/lib/addressable/uri.rb#L1510-L1536
train
sporkmonger/addressable
lib/addressable/uri.rb
Addressable.URI.path=
def path=(new_path) if new_path && !new_path.respond_to?(:to_str) raise TypeError, "Can't convert #{new_path.class} into String." end @path = (new_path || EMPTY_STR).to_str if !@path.empty? && @path[0..0] != SLASH && host != nil @path = "/#{@path}" end # Reset depend...
ruby
def path=(new_path) if new_path && !new_path.respond_to?(:to_str) raise TypeError, "Can't convert #{new_path.class} into String." end @path = (new_path || EMPTY_STR).to_str if !@path.empty? && @path[0..0] != SLASH && host != nil @path = "/#{@path}" end # Reset depend...
[ "def", "path", "=", "(", "new_path", ")", "if", "new_path", "&&", "!", "new_path", ".", "respond_to?", "(", ":to_str", ")", "raise", "TypeError", ",", "\"Can't convert #{new_path.class} into String.\"", "end", "@path", "=", "(", "new_path", "||", "EMPTY_STR", ")...
Sets the path component for this URI. @param [String, #to_str] new_path The new path component.
[ "Sets", "the", "path", "component", "for", "this", "URI", "." ]
5894c95a7768435cb46d1355954611dbd194832e
https://github.com/sporkmonger/addressable/blob/5894c95a7768435cb46d1355954611dbd194832e/lib/addressable/uri.rb#L1542-L1557
train
sporkmonger/addressable
lib/addressable/uri.rb
Addressable.URI.normalized_query
def normalized_query(*flags) return nil unless self.query return @normalized_query if defined?(@normalized_query) @normalized_query ||= begin modified_query_class = Addressable::URI::CharacterClasses::QUERY.dup # Make sure possible key-value pair delimiters are escaped. modifie...
ruby
def normalized_query(*flags) return nil unless self.query return @normalized_query if defined?(@normalized_query) @normalized_query ||= begin modified_query_class = Addressable::URI::CharacterClasses::QUERY.dup # Make sure possible key-value pair delimiters are escaped. modifie...
[ "def", "normalized_query", "(", "*", "flags", ")", "return", "nil", "unless", "self", ".", "query", "return", "@normalized_query", "if", "defined?", "(", "@normalized_query", ")", "@normalized_query", "||=", "begin", "modified_query_class", "=", "Addressable", "::",...
The query component for this URI, normalized. @return [String] The query component, normalized.
[ "The", "query", "component", "for", "this", "URI", "normalized", "." ]
5894c95a7768435cb46d1355954611dbd194832e
https://github.com/sporkmonger/addressable/blob/5894c95a7768435cb46d1355954611dbd194832e/lib/addressable/uri.rb#L1590-L1607
train
sporkmonger/addressable
lib/addressable/uri.rb
Addressable.URI.query=
def query=(new_query) if new_query && !new_query.respond_to?(:to_str) raise TypeError, "Can't convert #{new_query.class} into String." end @query = new_query ? new_query.to_str : nil # Reset dependent values remove_instance_variable(:@normalized_query) if defined?(@normalized_quer...
ruby
def query=(new_query) if new_query && !new_query.respond_to?(:to_str) raise TypeError, "Can't convert #{new_query.class} into String." end @query = new_query ? new_query.to_str : nil # Reset dependent values remove_instance_variable(:@normalized_query) if defined?(@normalized_quer...
[ "def", "query", "=", "(", "new_query", ")", "if", "new_query", "&&", "!", "new_query", ".", "respond_to?", "(", ":to_str", ")", "raise", "TypeError", ",", "\"Can't convert #{new_query.class} into String.\"", "end", "@query", "=", "new_query", "?", "new_query", "."...
Sets the query component for this URI. @param [String, #to_str] new_query The new query component.
[ "Sets", "the", "query", "component", "for", "this", "URI", "." ]
5894c95a7768435cb46d1355954611dbd194832e
https://github.com/sporkmonger/addressable/blob/5894c95a7768435cb46d1355954611dbd194832e/lib/addressable/uri.rb#L1613-L1622
train
sporkmonger/addressable
lib/addressable/uri.rb
Addressable.URI.query_values
def query_values(return_type=Hash) empty_accumulator = Array == return_type ? [] : {} if return_type != Hash && return_type != Array raise ArgumentError, "Invalid return type. Must be Hash or Array." end return nil if self.query == nil split_query = self.query.split("&").map do |pa...
ruby
def query_values(return_type=Hash) empty_accumulator = Array == return_type ? [] : {} if return_type != Hash && return_type != Array raise ArgumentError, "Invalid return type. Must be Hash or Array." end return nil if self.query == nil split_query = self.query.split("&").map do |pa...
[ "def", "query_values", "(", "return_type", "=", "Hash", ")", "empty_accumulator", "=", "Array", "==", "return_type", "?", "[", "]", ":", "{", "}", "if", "return_type", "!=", "Hash", "&&", "return_type", "!=", "Array", "raise", "ArgumentError", ",", "\"Invali...
Converts the query component to a Hash value. @param [Class] return_type The return type desired. Value must be either `Hash` or `Array`. @return [Hash, Array, nil] The query string parsed as a Hash or Array or nil if the query string is blank. @example Addressable::URI.parse("?one=1&two=2&three=3").quer...
[ "Converts", "the", "query", "component", "to", "a", "Hash", "value", "." ]
5894c95a7768435cb46d1355954611dbd194832e
https://github.com/sporkmonger/addressable/blob/5894c95a7768435cb46d1355954611dbd194832e/lib/addressable/uri.rb#L1644-L1672
train
sporkmonger/addressable
lib/addressable/uri.rb
Addressable.URI.query_values=
def query_values=(new_query_values) if new_query_values == nil self.query = nil return nil end if !new_query_values.is_a?(Array) if !new_query_values.respond_to?(:to_hash) raise TypeError, "Can't convert #{new_query_values.class} into Hash." end ...
ruby
def query_values=(new_query_values) if new_query_values == nil self.query = nil return nil end if !new_query_values.is_a?(Array) if !new_query_values.respond_to?(:to_hash) raise TypeError, "Can't convert #{new_query_values.class} into Hash." end ...
[ "def", "query_values", "=", "(", "new_query_values", ")", "if", "new_query_values", "==", "nil", "self", ".", "query", "=", "nil", "return", "nil", "end", "if", "!", "new_query_values", ".", "is_a?", "(", "Array", ")", "if", "!", "new_query_values", ".", "...
Sets the query component for this URI from a Hash object. An empty Hash or Array will result in an empty query string. @param [Hash, #to_hash, Array] new_query_values The new query values. @example uri.query_values = {:a => "a", :b => ["c", "d", "e"]} uri.query # => "a=a&b=c&b=d&b=e" uri.query_values =...
[ "Sets", "the", "query", "component", "for", "this", "URI", "from", "a", "Hash", "object", ".", "An", "empty", "Hash", "or", "Array", "will", "result", "in", "an", "empty", "query", "string", "." ]
5894c95a7768435cb46d1355954611dbd194832e
https://github.com/sporkmonger/addressable/blob/5894c95a7768435cb46d1355954611dbd194832e/lib/addressable/uri.rb#L1693-L1737
train
sporkmonger/addressable
lib/addressable/uri.rb
Addressable.URI.request_uri=
def request_uri=(new_request_uri) if !new_request_uri.respond_to?(:to_str) raise TypeError, "Can't convert #{new_request_uri.class} into String." end if self.absolute? && self.scheme !~ /^https?$/i raise InvalidURIError, "Cannot set an HTTP request URI for a non-HTTP URI." ...
ruby
def request_uri=(new_request_uri) if !new_request_uri.respond_to?(:to_str) raise TypeError, "Can't convert #{new_request_uri.class} into String." end if self.absolute? && self.scheme !~ /^https?$/i raise InvalidURIError, "Cannot set an HTTP request URI for a non-HTTP URI." ...
[ "def", "request_uri", "=", "(", "new_request_uri", ")", "if", "!", "new_request_uri", ".", "respond_to?", "(", ":to_str", ")", "raise", "TypeError", ",", "\"Can't convert #{new_request_uri.class} into String.\"", "end", "if", "self", ".", "absolute?", "&&", "self", ...
Sets the HTTP request URI for this URI. @param [String, #to_str] new_request_uri The new HTTP request URI.
[ "Sets", "the", "HTTP", "request", "URI", "for", "this", "URI", "." ]
5894c95a7768435cb46d1355954611dbd194832e
https://github.com/sporkmonger/addressable/blob/5894c95a7768435cb46d1355954611dbd194832e/lib/addressable/uri.rb#L1756-L1774
train
sporkmonger/addressable
lib/addressable/uri.rb
Addressable.URI.normalized_fragment
def normalized_fragment return nil unless self.fragment return @normalized_fragment if defined?(@normalized_fragment) @normalized_fragment ||= begin component = Addressable::URI.normalize_component( self.fragment, Addressable::URI::CharacterClasses::FRAGMENT ) ...
ruby
def normalized_fragment return nil unless self.fragment return @normalized_fragment if defined?(@normalized_fragment) @normalized_fragment ||= begin component = Addressable::URI.normalize_component( self.fragment, Addressable::URI::CharacterClasses::FRAGMENT ) ...
[ "def", "normalized_fragment", "return", "nil", "unless", "self", ".", "fragment", "return", "@normalized_fragment", "if", "defined?", "(", "@normalized_fragment", ")", "@normalized_fragment", "||=", "begin", "component", "=", "Addressable", "::", "URI", ".", "normaliz...
The fragment component for this URI, normalized. @return [String] The fragment component, normalized.
[ "The", "fragment", "component", "for", "this", "URI", "normalized", "." ]
5894c95a7768435cb46d1355954611dbd194832e
https://github.com/sporkmonger/addressable/blob/5894c95a7768435cb46d1355954611dbd194832e/lib/addressable/uri.rb#L1788-L1803
train
sporkmonger/addressable
lib/addressable/uri.rb
Addressable.URI.fragment=
def fragment=(new_fragment) if new_fragment && !new_fragment.respond_to?(:to_str) raise TypeError, "Can't convert #{new_fragment.class} into String." end @fragment = new_fragment ? new_fragment.to_str : nil # Reset dependent values remove_instance_variable(:@normalized_fragment) i...
ruby
def fragment=(new_fragment) if new_fragment && !new_fragment.respond_to?(:to_str) raise TypeError, "Can't convert #{new_fragment.class} into String." end @fragment = new_fragment ? new_fragment.to_str : nil # Reset dependent values remove_instance_variable(:@normalized_fragment) i...
[ "def", "fragment", "=", "(", "new_fragment", ")", "if", "new_fragment", "&&", "!", "new_fragment", ".", "respond_to?", "(", ":to_str", ")", "raise", "TypeError", ",", "\"Can't convert #{new_fragment.class} into String.\"", "end", "@fragment", "=", "new_fragment", "?",...
Sets the fragment component for this URI. @param [String, #to_str] new_fragment The new fragment component.
[ "Sets", "the", "fragment", "component", "for", "this", "URI", "." ]
5894c95a7768435cb46d1355954611dbd194832e
https://github.com/sporkmonger/addressable/blob/5894c95a7768435cb46d1355954611dbd194832e/lib/addressable/uri.rb#L1809-L1821
train
sporkmonger/addressable
lib/addressable/uri.rb
Addressable.URI.join
def join(uri) if !uri.respond_to?(:to_str) raise TypeError, "Can't convert #{uri.class} into String." end if !uri.kind_of?(URI) # Otherwise, convert to a String, then parse. uri = URI.parse(uri.to_str) end if uri.to_s.empty? return self.dup end ...
ruby
def join(uri) if !uri.respond_to?(:to_str) raise TypeError, "Can't convert #{uri.class} into String." end if !uri.kind_of?(URI) # Otherwise, convert to a String, then parse. uri = URI.parse(uri.to_str) end if uri.to_s.empty? return self.dup end ...
[ "def", "join", "(", "uri", ")", "if", "!", "uri", ".", "respond_to?", "(", ":to_str", ")", "raise", "TypeError", ",", "\"Can't convert #{uri.class} into String.\"", "end", "if", "!", "uri", ".", "kind_of?", "(", "URI", ")", "# Otherwise, convert to a String, then ...
Joins two URIs together. @param [String, Addressable::URI, #to_str] The URI to join with. @return [Addressable::URI] The joined URI.
[ "Joins", "two", "URIs", "together", "." ]
5894c95a7768435cb46d1355954611dbd194832e
https://github.com/sporkmonger/addressable/blob/5894c95a7768435cb46d1355954611dbd194832e/lib/addressable/uri.rb#L1863-L1955
train
sporkmonger/addressable
lib/addressable/uri.rb
Addressable.URI.normalize
def normalize # This is a special exception for the frequently misused feed # URI scheme. if normalized_scheme == "feed" if self.to_s =~ /^feed:\/*http:\/*/ return URI.parse( self.to_s[/^feed:\/*(http:\/*.*)/, 1] ).normalize end end return s...
ruby
def normalize # This is a special exception for the frequently misused feed # URI scheme. if normalized_scheme == "feed" if self.to_s =~ /^feed:\/*http:\/*/ return URI.parse( self.to_s[/^feed:\/*(http:\/*.*)/, 1] ).normalize end end return s...
[ "def", "normalize", "# This is a special exception for the frequently misused feed", "# URI scheme.", "if", "normalized_scheme", "==", "\"feed\"", "if", "self", ".", "to_s", "=~", "/", "\\/", "\\/", "/", "return", "URI", ".", "parse", "(", "self", ".", "to_s", "[", ...
Returns a normalized URI object. NOTE: This method does not attempt to fully conform to specifications. It exists largely to correct other people's failures to read the specifications, and also to deal with caching issues since several different URIs may represent the same resource and should not be cached multip...
[ "Returns", "a", "normalized", "URI", "object", "." ]
5894c95a7768435cb46d1355954611dbd194832e
https://github.com/sporkmonger/addressable/blob/5894c95a7768435cb46d1355954611dbd194832e/lib/addressable/uri.rb#L2138-L2156
train
sporkmonger/addressable
lib/addressable/uri.rb
Addressable.URI.defer_validation
def defer_validation(&block) raise LocalJumpError, "No block given." unless block @validation_deferred = true block.call() @validation_deferred = false validate return nil end
ruby
def defer_validation(&block) raise LocalJumpError, "No block given." unless block @validation_deferred = true block.call() @validation_deferred = false validate return nil end
[ "def", "defer_validation", "(", "&", "block", ")", "raise", "LocalJumpError", ",", "\"No block given.\"", "unless", "block", "@validation_deferred", "=", "true", "block", ".", "call", "(", ")", "@validation_deferred", "=", "false", "validate", "return", "nil", "en...
This method allows you to make several changes to a URI simultaneously, which separately would cause validation errors, but in conjunction, are valid. The URI will be revalidated as soon as the entire block has been executed. @param [Proc] block A set of operations to perform on a given URI.
[ "This", "method", "allows", "you", "to", "make", "several", "changes", "to", "a", "URI", "simultaneously", "which", "separately", "would", "cause", "validation", "errors", "but", "in", "conjunction", "are", "valid", ".", "The", "URI", "will", "be", "revalidate...
5894c95a7768435cb46d1355954611dbd194832e
https://github.com/sporkmonger/addressable/blob/5894c95a7768435cb46d1355954611dbd194832e/lib/addressable/uri.rb#L2370-L2377
train
sporkmonger/addressable
lib/addressable/uri.rb
Addressable.URI.validate
def validate return if !!@validation_deferred if self.scheme != nil && self.ip_based? && (self.host == nil || self.host.empty?) && (self.path == nil || self.path.empty?) raise InvalidURIError, "Absolute URI missing hierarchical segment: '#{self.to_s}'" end i...
ruby
def validate return if !!@validation_deferred if self.scheme != nil && self.ip_based? && (self.host == nil || self.host.empty?) && (self.path == nil || self.path.empty?) raise InvalidURIError, "Absolute URI missing hierarchical segment: '#{self.to_s}'" end i...
[ "def", "validate", "return", "if", "!", "!", "@validation_deferred", "if", "self", ".", "scheme", "!=", "nil", "&&", "self", ".", "ip_based?", "&&", "(", "self", ".", "host", "==", "nil", "||", "self", ".", "host", ".", "empty?", ")", "&&", "(", "sel...
Ensures that the URI is valid.
[ "Ensures", "that", "the", "URI", "is", "valid", "." ]
5894c95a7768435cb46d1355954611dbd194832e
https://github.com/sporkmonger/addressable/blob/5894c95a7768435cb46d1355954611dbd194832e/lib/addressable/uri.rb#L2425-L2459
train
sporkmonger/addressable
lib/addressable/uri.rb
Addressable.URI.replace_self
def replace_self(uri) # Reset dependent values instance_variables.each do |var| if instance_variable_defined?(var) && var != :@validation_deferred remove_instance_variable(var) end end @scheme = uri.scheme @user = uri.user @password = uri.password @ho...
ruby
def replace_self(uri) # Reset dependent values instance_variables.each do |var| if instance_variable_defined?(var) && var != :@validation_deferred remove_instance_variable(var) end end @scheme = uri.scheme @user = uri.user @password = uri.password @ho...
[ "def", "replace_self", "(", "uri", ")", "# Reset dependent values", "instance_variables", ".", "each", "do", "|", "var", "|", "if", "instance_variable_defined?", "(", "var", ")", "&&", "var", "!=", ":@validation_deferred", "remove_instance_variable", "(", "var", ")"...
Replaces the internal state of self with the specified URI's state. Used in destructive operations to avoid massive code repetition. @param [Addressable::URI] uri The URI to replace <code>self</code> with. @return [Addressable::URI] <code>self</code>.
[ "Replaces", "the", "internal", "state", "of", "self", "with", "the", "specified", "URI", "s", "state", ".", "Used", "in", "destructive", "operations", "to", "avoid", "massive", "code", "repetition", "." ]
5894c95a7768435cb46d1355954611dbd194832e
https://github.com/sporkmonger/addressable/blob/5894c95a7768435cb46d1355954611dbd194832e/lib/addressable/uri.rb#L2468-L2485
train
Dynamoid/dynamoid
lib/dynamoid/fields.rb
Dynamoid.Fields.write_attribute
def write_attribute(name, value) name = name.to_sym if association = @associations[name] association.reset end @attributes_before_type_cast[name] = value value_casted = TypeCasting.cast_field(value, self.class.attributes[name]) attributes[name] = value_casted end
ruby
def write_attribute(name, value) name = name.to_sym if association = @associations[name] association.reset end @attributes_before_type_cast[name] = value value_casted = TypeCasting.cast_field(value, self.class.attributes[name]) attributes[name] = value_casted end
[ "def", "write_attribute", "(", "name", ",", "value", ")", "name", "=", "name", ".", "to_sym", "if", "association", "=", "@associations", "[", "name", "]", "association", ".", "reset", "end", "@attributes_before_type_cast", "[", "name", "]", "=", "value", "va...
Write an attribute on the object. Also marks the previous value as dirty. @param [Symbol] name the name of the field @param [Object] value the value to assign to that field @since 0.2.0
[ "Write", "an", "attribute", "on", "the", "object", ".", "Also", "marks", "the", "previous", "value", "as", "dirty", "." ]
9e3d006b039e45877b003564ded65509b10b6354
https://github.com/Dynamoid/dynamoid/blob/9e3d006b039e45877b003564ded65509b10b6354/lib/dynamoid/fields.rb#L117-L128
train
Dynamoid/dynamoid
lib/dynamoid/fields.rb
Dynamoid.Fields.set_created_at
def set_created_at self.created_at ||= DateTime.now.in_time_zone(Time.zone) if Dynamoid::Config.timestamps end
ruby
def set_created_at self.created_at ||= DateTime.now.in_time_zone(Time.zone) if Dynamoid::Config.timestamps end
[ "def", "set_created_at", "self", ".", "created_at", "||=", "DateTime", ".", "now", ".", "in_time_zone", "(", "Time", ".", "zone", ")", "if", "Dynamoid", "::", "Config", ".", "timestamps", "end" ]
Automatically called during the created callback to set the created_at time. @since 0.2.0
[ "Automatically", "called", "during", "the", "created", "callback", "to", "set", "the", "created_at", "time", "." ]
9e3d006b039e45877b003564ded65509b10b6354
https://github.com/Dynamoid/dynamoid/blob/9e3d006b039e45877b003564ded65509b10b6354/lib/dynamoid/fields.rb#L160-L162
train
Dynamoid/dynamoid
lib/dynamoid/fields.rb
Dynamoid.Fields.set_updated_at
def set_updated_at if Dynamoid::Config.timestamps && !updated_at_changed? self.updated_at = DateTime.now.in_time_zone(Time.zone) end end
ruby
def set_updated_at if Dynamoid::Config.timestamps && !updated_at_changed? self.updated_at = DateTime.now.in_time_zone(Time.zone) end end
[ "def", "set_updated_at", "if", "Dynamoid", "::", "Config", ".", "timestamps", "&&", "!", "updated_at_changed?", "self", ".", "updated_at", "=", "DateTime", ".", "now", ".", "in_time_zone", "(", "Time", ".", "zone", ")", "end", "end" ]
Automatically called during the save callback to set the updated_at time. @since 0.2.0
[ "Automatically", "called", "during", "the", "save", "callback", "to", "set", "the", "updated_at", "time", "." ]
9e3d006b039e45877b003564ded65509b10b6354
https://github.com/Dynamoid/dynamoid/blob/9e3d006b039e45877b003564ded65509b10b6354/lib/dynamoid/fields.rb#L167-L171
train
Dynamoid/dynamoid
lib/dynamoid/document.rb
Dynamoid.Document.reload
def reload options = { consistent_read: true } if self.class.range_key options[:range_key] = range_value end self.attributes = self.class.find(hash_key, options).attributes @associations.values.each(&:reset) self end
ruby
def reload options = { consistent_read: true } if self.class.range_key options[:range_key] = range_value end self.attributes = self.class.find(hash_key, options).attributes @associations.values.each(&:reset) self end
[ "def", "reload", "options", "=", "{", "consistent_read", ":", "true", "}", "if", "self", ".", "class", ".", "range_key", "options", "[", ":range_key", "]", "=", "range_value", "end", "self", ".", "attributes", "=", "self", ".", "class", ".", "find", "(",...
An object is equal to another object if their ids are equal. @since 0.2.0 Reload an object from the database -- if you suspect the object has changed in the datastore and you need those changes to be reflected immediately, you would call this method. This is a consistent read. @return [Dynamoid::Document] the doc...
[ "An", "object", "is", "equal", "to", "another", "object", "if", "their", "ids", "are", "equal", "." ]
9e3d006b039e45877b003564ded65509b10b6354
https://github.com/Dynamoid/dynamoid/blob/9e3d006b039e45877b003564ded65509b10b6354/lib/dynamoid/document.rb#L374-L384
train
Dynamoid/dynamoid
lib/dynamoid/document.rb
Dynamoid.Document.evaluate_default_value
def evaluate_default_value(val) if val.respond_to?(:call) val.call elsif val.duplicable? val.dup else val end end
ruby
def evaluate_default_value(val) if val.respond_to?(:call) val.call elsif val.duplicable? val.dup else val end end
[ "def", "evaluate_default_value", "(", "val", ")", "if", "val", ".", "respond_to?", "(", ":call", ")", "val", ".", "call", "elsif", "val", ".", "duplicable?", "val", ".", "dup", "else", "val", "end", "end" ]
Evaluates the default value given, this is used by undump when determining the value of the default given for a field options. @param [Object] :value the attribute's default value
[ "Evaluates", "the", "default", "value", "given", "this", "is", "used", "by", "undump", "when", "determining", "the", "value", "of", "the", "default", "given", "for", "a", "field", "options", "." ]
9e3d006b039e45877b003564ded65509b10b6354
https://github.com/Dynamoid/dynamoid/blob/9e3d006b039e45877b003564ded65509b10b6354/lib/dynamoid/document.rb#L420-L428
train
Dynamoid/dynamoid
lib/dynamoid/persistence.rb
Dynamoid.Persistence.touch
def touch(name = nil) now = DateTime.now self.updated_at = now attributes[name] = now if name save end
ruby
def touch(name = nil) now = DateTime.now self.updated_at = now attributes[name] = now if name save end
[ "def", "touch", "(", "name", "=", "nil", ")", "now", "=", "DateTime", ".", "now", "self", ".", "updated_at", "=", "now", "attributes", "[", "name", "]", "=", "now", "if", "name", "save", "end" ]
Set updated_at and any passed in field to current DateTime. Useful for things like last_login_at, etc.
[ "Set", "updated_at", "and", "any", "passed", "in", "field", "to", "current", "DateTime", ".", "Useful", "for", "things", "like", "last_login_at", "etc", "." ]
9e3d006b039e45877b003564ded65509b10b6354
https://github.com/Dynamoid/dynamoid/blob/9e3d006b039e45877b003564ded65509b10b6354/lib/dynamoid/persistence.rb#L123-L128
train
Dynamoid/dynamoid
lib/dynamoid/persistence.rb
Dynamoid.Persistence.save
def save(_options = {}) self.class.create_table if new_record? conditions = { unless_exists: [self.class.hash_key] } conditions[:unless_exists] << range_key if range_key run_callbacks(:create) { persist(conditions) } else persist end end
ruby
def save(_options = {}) self.class.create_table if new_record? conditions = { unless_exists: [self.class.hash_key] } conditions[:unless_exists] << range_key if range_key run_callbacks(:create) { persist(conditions) } else persist end end
[ "def", "save", "(", "_options", "=", "{", "}", ")", "self", ".", "class", ".", "create_table", "if", "new_record?", "conditions", "=", "{", "unless_exists", ":", "[", "self", ".", "class", ".", "hash_key", "]", "}", "conditions", "[", ":unless_exists", "...
Run the callbacks and then persist this object in the datastore. @since 0.2.0
[ "Run", "the", "callbacks", "and", "then", "persist", "this", "object", "in", "the", "datastore", "." ]
9e3d006b039e45877b003564ded65509b10b6354
https://github.com/Dynamoid/dynamoid/blob/9e3d006b039e45877b003564ded65509b10b6354/lib/dynamoid/persistence.rb#L140-L151
train