_id
stringlengths 2
6
| title
stringlengths 9
130
| partition
stringclasses 3
values | text
stringlengths 30
4.3k
| language
stringclasses 1
value | meta_information
dict |
---|---|---|---|---|---|
q25700
|
SourceRoute.TraceFilter.block_it?
|
validation
|
def block_it?(tp)
if @cond.track_params
return true if negative_check(tp)
if positives_check(tp)
return !tp.binding.eval('local_variables').any? do |v|
tp.binding.local_variable_get(v).object_id == @cond.track_params
end
|
ruby
|
{
"resource": ""
}
|
q25701
|
OnedClusterer.Clusterer.classify
|
validation
|
def classify(value)
raise ArgumentError, "value: #{value} must be in data array" unless @data.include?(value)
|
ruby
|
{
"resource": ""
}
|
q25702
|
OnedClusterer.Clusterer.intervals
|
validation
|
def intervals
first, *rest = bounds.each_cons(2).to_a
[first, *rest.map {|lower,
|
ruby
|
{
"resource": ""
}
|
q25703
|
OnedClusterer.Jenks.matrices
|
validation
|
def matrices
rows = data.size
cols = n_classes
# in the original implementation, these matrices are referred to
# as `LC` and `OP`
# * lower_class_limits (LC): optimal lower class limits
# * variance_combinations (OP): optimal variance combinations for all classes
lower_class_limits = *Matrix.zero(rows + 1, cols + 1)
variance_combinations = *Matrix.zero(rows + 1, cols + 1)
# the variance, as computed at each step in the calculation
variance = 0
for i in 1..cols
lower_class_limits[1][i] = 1
variance_combinations[1][i] = 0
for j in 2..rows
variance_combinations[j][i] = Float::INFINITY
end
end
for l in 2..rows
sum = 0 # `SZ` originally. this is the sum of the values seen thus far when calculating variance.
sum_squares = 0 # `ZSQ` originally. the sum of squares of values seen thus far
w = 0 # `WT` originally. This is the number of data points considered so far.
for m in
|
ruby
|
{
"resource": ""
}
|
q25704
|
Omdb.Api.fetch
|
validation
|
def fetch(title, year = "", tomatoes = false, plot = "short")
res = network.call({ t: title, y: year, tomatoes: tomatoes, plot: plot })
if res[:data]["Response"] == "False"
|
ruby
|
{
"resource": ""
}
|
q25705
|
Omdb.Api.find
|
validation
|
def find(id, tomatoes = false, plot = "short")
res = network.call({ i: id, tomatoes: tomatoes, plot: plot })
if res[:data]["Response"] == "False"
|
ruby
|
{
"resource": ""
}
|
q25706
|
G5AuthenticationClient.Configuration.options
|
validation
|
def options
VALID_CONFIG_OPTIONS.inject({}) do |option, key|
|
ruby
|
{
"resource": ""
}
|
q25707
|
G5AuthenticationClient.Client.create_user
|
validation
|
def create_user(options={})
user=User.new(options)
user.validate_for_create!
body = user_hash(user.to_hash)
|
ruby
|
{
"resource": ""
}
|
q25708
|
G5AuthenticationClient.Client.update_user
|
validation
|
def update_user(options={})
user=User.new(options)
user.validate!
response=oauth_access_token.put("/v1/users/#{user.id}",
|
ruby
|
{
"resource": ""
}
|
q25709
|
G5AuthenticationClient.Client.find_user_by_email
|
validation
|
def find_user_by_email(email)
response = oauth_access_token.get('/v1/users', params: { email: email })
user = response.parsed.first
|
ruby
|
{
"resource": ""
}
|
q25710
|
G5AuthenticationClient.Client.sign_out_url
|
validation
|
def sign_out_url(redirect_url=nil)
auth_server_url = Addressable::URI.parse(endpoint)
auth_server_url.path = '/users/sign_out'
auth_server_url.query_values
|
ruby
|
{
"resource": ""
}
|
q25711
|
G5AuthenticationClient.Client.list_users
|
validation
|
def list_users
response=oauth_access_token.get("/v1/users")
|
ruby
|
{
"resource": ""
}
|
q25712
|
G5AuthenticationClient.Client.list_roles
|
validation
|
def list_roles
response = oauth_access_token.get('/v1/roles')
|
ruby
|
{
"resource": ""
}
|
q25713
|
CloudApp.Client.bookmark
|
validation
|
def bookmark(*args)
if args[0].is_a? Array
Drop.create(:bookmarks, args)
else
url, name = args[0], (args[1] || "")
|
ruby
|
{
"resource": ""
}
|
q25714
|
CloudApp.Client.rename
|
validation
|
def rename(id, name = "")
drop =
|
ruby
|
{
"resource": ""
}
|
q25715
|
CloudApp.Client.privacy
|
validation
|
def privacy(id, privacy = false)
drop
|
ruby
|
{
"resource": ""
}
|
q25716
|
CloudApp.Base.load
|
validation
|
def load(attributes = {})
attributes.each do |key, val|
if key =~ /^.*_at$/ and val
# if this is a date/time key and it's not nil, try to parse it first
# as DateTime, then as Date only
begin
dt = DateTime.strptime(val, "%Y-%m-%dT%H:%M:%SZ")
newval = Time.utc(dt.year, dt.month, dt.day, dt.hour, dt.min, dt.sec)
rescue ArgumentError => ex
|
ruby
|
{
"resource": ""
}
|
q25717
|
WDSinatra.AppLoader.load_environment
|
validation
|
def load_environment(env=RACK_ENV)
# Load the default which can be overwritten or extended by specific
# env config files.
require File.join(root_path, 'config', 'environments', 'default.rb')
env_file = File.join(root_path, "config", "environments", "#{env}.rb")
if File.exist?(env_file)
require env_file
else
debug_msg = "Environment file: #{env_file} couldn't be found,
|
ruby
|
{
"resource": ""
}
|
q25718
|
WDSinatra.AppLoader.load_apis
|
validation
|
def load_apis
Dir.glob(File.join(root_path, "api", "**", "*.rb")).each do
|
ruby
|
{
"resource": ""
}
|
q25719
|
IsItWorking.Filter.run
|
validation
|
def run
status = Status.new(name)
runner = (async ? AsyncRunner : SyncRunner).new do
t = Time.now
begin
@check.call(status)
|
ruby
|
{
"resource": ""
}
|
q25720
|
IsItWorking.Handler.call
|
validation
|
def call(env)
if @app.nil? || env[PATH_INFO] == @route_path
statuses = []
t = Time.now
statuses = Filter.run_filters(@filters)
|
ruby
|
{
"resource": ""
}
|
q25721
|
IsItWorking.Handler.check
|
validation
|
def check (name, *options_or_check, &block)
raise ArgumentError("Too many arguments to #{self.class.name}#check") if options_or_check.size > 2
check = nil
options = {:async => true}
unless options_or_check.empty?
if options_or_check[0].is_a?(Hash)
options = options.merge(options_or_check[0])
|
ruby
|
{
"resource": ""
}
|
q25722
|
IsItWorking.Handler.lookup_check
|
validation
|
def lookup_check(name, options) #:nodoc:
check_class_name = "#{name.to_s.gsub(/(^|_)([a-z])/){|m| m.sub('_', '').upcase}}Check"
check = nil
if IsItWorking.const_defined?(check_class_name)
check_class = IsItWorking.const_get(check_class_name)
|
ruby
|
{
"resource": ""
}
|
q25723
|
IsItWorking.Handler.render
|
validation
|
def render(statuses, elapsed_time) #:nodoc:
fail = statuses.all?{|s| s.success?}
headers = {
"Content-Type" => "text/plain; charset=utf8",
"Cache-Control" => "no-cache",
"Date" => Time.now.httpdate,
}
messages = []
statuses.each do |status|
status.messages.each do |m|
messages << "#{m.ok? ? 'OK: ' : 'FAIL:'} #{status.name} - #{m.message} (#{status.time ? sprintf('%0.000f', status.time * 1000) : '?'}ms)"
end
end
info = []
|
ruby
|
{
"resource": ""
}
|
q25724
|
IsItWorking.PingCheck.call
|
validation
|
def call(status)
begin
ping(@host, @port)
status.ok("#{@alias} is accepting connections on port #{@port.inspect}")
rescue Errno::ECONNREFUSED
status.fail("#{@alias} is not accepting connections on port #{@port.inspect}")
rescue SocketError => e
|
ruby
|
{
"resource": ""
}
|
q25725
|
BootstrapAdmin.ControllerHelpers.respond_to?
|
validation
|
def respond_to? method, include_private = false
true if bootstrap_admin_config.respond_to?
|
ruby
|
{
"resource": ""
}
|
q25726
|
IsItWorking.UrlCheck.instantiate_http
|
validation
|
def instantiate_http #:nodoc:
http_class = nil
if @proxy && @proxy[:host]
http_class = Net::HTTP::Proxy(@proxy[:host], @proxy[:port], @proxy[:username], @proxy[:password])
else
http_class = Net::HTTP
end
http = http_class.new(@uri.host, @uri.port)
if @uri.scheme == 'https'
|
ruby
|
{
"resource": ""
}
|
q25727
|
IsItWorking.UrlCheck.perform_http_request
|
validation
|
def perform_http_request #:nodoc:
request = Net::HTTP::Get.new(@uri.request_uri, @headers)
request.basic_auth(@username, @password)
|
ruby
|
{
"resource": ""
}
|
q25728
|
Ftdi.Context.usb_open
|
validation
|
def usb_open(vendor, product)
raise ArgumentError.new('vendor should be Fixnum') unless vendor.kind_of?(Fixnum)
raise ArgumentError.new('product should
|
ruby
|
{
"resource": ""
}
|
q25729
|
Ftdi.Context.usb_open_desc
|
validation
|
def usb_open_desc(vendor, product, description, serial)
raise ArgumentError.new('vendor should be Fixnum') unless vendor.kind_of?(Fixnum)
raise ArgumentError.new('product should
|
ruby
|
{
"resource": ""
}
|
q25730
|
Ftdi.Context.usb_open_desc_index
|
validation
|
def usb_open_desc_index(vendor, product, description, serial, index)
raise ArgumentError.new('vendor should be Fixnum') unless vendor.kind_of?(Fixnum)
raise ArgumentError.new('product should be Fixnum') unless product.kind_of?(Fixnum)
raise ArgumentError.new('index should be Fixnum') unless index.kind_of?(Fixnum)
|
ruby
|
{
"resource": ""
}
|
q25731
|
Ftdi.Context.baudrate=
|
validation
|
def baudrate=(new_baudrate)
raise ArgumentError.new('baudrate should be Fixnum') unless new_baudrate.kind_of?(Fixnum)
|
ruby
|
{
"resource": ""
}
|
q25732
|
Ftdi.Context.write_data_chunksize
|
validation
|
def write_data_chunksize
p = FFI::MemoryPointer.new(:uint,
|
ruby
|
{
"resource": ""
}
|
q25733
|
Ftdi.Context.write_data
|
validation
|
def write_data(bytes)
bytes = bytes.pack('c*') if bytes.respond_to?(:pack)
size = bytes.respond_to?(:bytesize) ? bytes.bytesize : bytes.size
mem_buf = FFI::MemoryPointer.new(:char, size)
mem_buf.put_bytes(0, bytes)
|
ruby
|
{
"resource": ""
}
|
q25734
|
Ftdi.Context.read_data_chunksize
|
validation
|
def read_data_chunksize
p = FFI::MemoryPointer.new(:uint,
|
ruby
|
{
"resource": ""
}
|
q25735
|
Ftdi.Context.read_data
|
validation
|
def read_data
chunksize = read_data_chunksize
p = FFI::MemoryPointer.new(:char, chunksize)
bytes_read = Ftdi.ftdi_read_data(ctx, p,
|
ruby
|
{
"resource": ""
}
|
q25736
|
Ftdi.Context.read_pins
|
validation
|
def read_pins
p = FFI::MemoryPointer.new(:uchar,
|
ruby
|
{
"resource": ""
}
|
q25737
|
Geos::GoogleMaps::Api2.Geometry.to_g_marker_api2
|
validation
|
def to_g_marker_api2(marker_options = {}, options = {})
klass = if options[:short_class]
'GMarker'
else
'google.maps.Marker'
end
|
ruby
|
{
"resource": ""
}
|
q25738
|
Geos::GoogleMaps::Api2.CoordinateSequence.to_g_polyline_api2
|
validation
|
def to_g_polyline_api2(polyline_options = {}, options = {})
klass = if options[:short_class]
'GPolyline'
else
'google.maps.Polyline'
end
poly_opts = if polyline_options[:polyline_options]
Geos::Helper.camelize_keys(polyline_options[:polyline_options])
end
args = [
(polyline_options[:color] ? "'#{Geos::Helper.escape_javascript(polyline_options[:color])}'" : 'null'),
|
ruby
|
{
"resource": ""
}
|
q25739
|
Geos::GoogleMaps::Api2.CoordinateSequence.to_g_polygon_api2
|
validation
|
def to_g_polygon_api2(polygon_options = {}, options = {})
klass = if options[:short_class]
'GPolygon'
else
'google.maps.Polygon'
end
poly_opts = if polygon_options[:polygon_options]
Geos::Helper.camelize_keys(polygon_options[:polygon_options])
end
args = [
(polygon_options[:stroke_color] ? "'#{Geos::Helper.escape_javascript(polygon_options[:stroke_color])}'" : 'null'),
(polygon_options[:stroke_weight] || 'null'),
(polygon_options[:stroke_opacity] || 'null'),
(polygon_options[:fill_color] ?
|
ruby
|
{
"resource": ""
}
|
q25740
|
Geos.Geometry.to_bbox
|
validation
|
def to_bbox(long_or_short_names = :long)
case long_or_short_names
when :long
{
:north => self.north,
:east => self.east,
:south => self.south,
:west => self.west
}
when :short
{
:n => self.north,
:e => self.east,
|
ruby
|
{
"resource": ""
}
|
q25741
|
Geos.Point.to_georss
|
validation
|
def to_georss(*args)
xml = Geos::Helper.xml_options(*args)[0]
xml.georss(:where) do
xml.gml(:Point) do
|
ruby
|
{
"resource": ""
}
|
q25742
|
Geos::GoogleMaps.Api3::Geometry.to_g_marker_api3
|
validation
|
def to_g_marker_api3(marker_options = {}, options = {})
options = {
:escape => [],
:lat_lng_options => {}
}.merge(options)
opts = Geos::Helper.camelize_keys(marker_options)
|
ruby
|
{
"resource": ""
}
|
q25743
|
Geos::GoogleMaps.Api3::CoordinateSequence.to_g_polyline_api3
|
validation
|
def to_g_polyline_api3(polyline_options = {}, options = {})
options = {
:escape => [],
:lat_lng_options => {}
}.merge(options)
opts = Geos::Helper.camelize_keys(polyline_options)
opts[:path] = "[#{self.to_g_lat_lng_api3(options[:lat_lng_options]).join(', ')}]"
json =
|
ruby
|
{
"resource": ""
}
|
q25744
|
Geos.CoordinateSequence.to_georss
|
validation
|
def to_georss(*args)
xml = Geos::Helper.xml_options(*args)[0]
xml.georss(:where) do
xml.gml(:LineString) do
xml.gml(:posList) do
xml << self.to_a.collect do |p|
|
ruby
|
{
"resource": ""
}
|
q25745
|
SolidusImportProducts.ProcessRow.convert_to_price
|
validation
|
def convert_to_price(price_str)
raise SolidusImportProducts::Exception::InvalidPrice unless price_str
punt = price_str.index('.')
coma = price_str.index(',')
if !coma.nil? &&
|
ruby
|
{
"resource": ""
}
|
q25746
|
SynchronizedModel.Support.matches
|
validation
|
def matches(regexp, word)
if regexp.respond_to?(:match?)
|
ruby
|
{
"resource": ""
}
|
q25747
|
Geos.Polygon.dump_points
|
validation
|
def dump_points(cur_path = [])
points = [ self.exterior_ring.dump_points ]
|
ruby
|
{
"resource": ""
}
|
q25748
|
PruneAr.ForeignKeyHandler.generate_belongs_to_foreign_key_name
|
validation
|
def generate_belongs_to_foreign_key_name(assoc)
source = assoc.source_table[0..7]
column = assoc.foreign_key_column[0..7]
destination =
|
ruby
|
{
"resource": ""
}
|
q25749
|
EGPRates.CIB.raw_exchange_rates
|
validation
|
def raw_exchange_rates
req = Net::HTTP::Post.new(@uri, 'Content-Type' => 'application/json')
req.body = { lang: :en }.to_json
response = Net::HTTP.start(@uri.hostname, @uri.port) do |http|
http.request(req)
end
fail ResponseError, response.code unless
|
ruby
|
{
"resource": ""
}
|
q25750
|
Respect.FormatValidator.validate_ipv4_addr
|
validation
|
def validate_ipv4_addr(value)
ipaddr = IPAddr.new(value)
unless ipaddr.ipv4?
raise ValidationError, "IP address '#{value}' is not IPv4"
end
|
ruby
|
{
"resource": ""
}
|
q25751
|
Respect.FormatValidator.validate_ipv6_addr
|
validation
|
def validate_ipv6_addr(value)
ipaddr = IPAddr.new(value)
unless ipaddr.ipv6?
raise ValidationError, "IP address '#{value}' is not IPv6"
end
|
ruby
|
{
"resource": ""
}
|
q25752
|
LazyLazer.InternalModel.to_h
|
validation
|
def to_h(strict: false)
todo = @key_metadata.keys - @cache.keys
todo.each_with_object({}) do |key, hsh|
|
ruby
|
{
"resource": ""
}
|
q25753
|
LazyLazer.InternalModel.exists_locally?
|
validation
|
def exists_locally?(key_name)
return true if @cache.key?(key_name) || @writethrough.key?(key_name)
|
ruby
|
{
"resource": ""
}
|
q25754
|
LazyLazer.InternalModel.write_attribute
|
validation
|
def write_attribute(key_name, new_value)
meta = ensure_metadata_exists(key_name)
@source.delete(meta.source_key)
|
ruby
|
{
"resource": ""
}
|
q25755
|
LazyLazer.InternalModel.delete_attribute
|
validation
|
def delete_attribute(key_name)
key_name_sym = key_name.to_sym
meta = ensure_metadata_exists(key_name_sym)
@cache.delete(key_name)
|
ruby
|
{
"resource": ""
}
|
q25756
|
LazyLazer.InternalModel.verify_required!
|
validation
|
def verify_required!
@key_metadata.required_properties.each do |key_name|
next if @source.key?(@key_metadata.get(key_name).source_key)
|
ruby
|
{
"resource": ""
}
|
q25757
|
LazyLazer.InternalModel.transform_value
|
validation
|
def transform_value(value, transform)
case transform
when nil
value
when Proc
@parent.instance_exec(value, &transform)
|
ruby
|
{
"resource": ""
}
|
q25758
|
EGPRates.Bank.response
|
validation
|
def response
response = Net::HTTP.get_response(@uri)
if response.is_a? Net::HTTPRedirection
response =
|
ruby
|
{
"resource": ""
}
|
q25759
|
EGPRates.ADIB.currencies
|
validation
|
def currencies(table_rows)
table_rows.lazy.map do |e|
e.css('img').map { |img|
|
ruby
|
{
"resource": ""
}
|
q25760
|
LazyLazer.KeyMetadataStore.add
|
validation
|
def add(key, meta)
@collection[key] = meta
if meta.required?
@required_properties << key
else
|
ruby
|
{
"resource": ""
}
|
q25761
|
Respect.HasConstraints.validate_constraints
|
validation
|
def validate_constraints(value)
options.each do |option, arg|
if validator_class = Respect.validator_for(option)
|
ruby
|
{
"resource": ""
}
|
q25762
|
Respect.HasConstraints.validate
|
validation
|
def validate(object)
sanitized_object = validate_type(object)
validate_constraints(sanitized_object) unless sanitized_object.nil? && allow_nil?
self.sanitized_object = sanitized_object
true
|
ruby
|
{
"resource": ""
}
|
q25763
|
Respect.HashSchema.[]=
|
validation
|
def []=(name, schema)
case name
when Symbol, String, Regexp
if @properties.has_key?(name)
raise InvalidSchemaError, "property '#{name}'
|
ruby
|
{
"resource": ""
}
|
q25764
|
Respect.HashDef.[]=
|
validation
|
def []=(key, value)
case value
when String
string(key, equal_to:
|
ruby
|
{
"resource": ""
}
|
q25765
|
GoogleHolidayCalendar.Calendar.holiday?
|
validation
|
def holiday?(arg)
date = to_date(arg)
holidays(start_date: date, end_date:
|
ruby
|
{
"resource": ""
}
|
q25766
|
Choice.Parser.arrayize_arguments
|
validation
|
def arrayize_arguments(args)
# Go through trailing arguments and suck them in if they don't seem
# to have an owner.
array
|
ruby
|
{
"resource": ""
}
|
q25767
|
Choice.Option.to_a
|
validation
|
def to_a
[
required,
short,
long,
desc,
|
ruby
|
{
"resource": ""
}
|
q25768
|
Choice.Option.to_h
|
validation
|
def to_h
{
"required" => required,
"short" => short,
"long" => long,
"desc" => desc,
"default" => default,
|
ruby
|
{
"resource": ""
}
|
q25769
|
EventHub.Configuration.parse_options
|
validation
|
def parse_options(argv = ARGV)
@config_file = File.join(Dir.getwd, 'config', "#{@name}.json")
OptionParser.new do |opts|
note = 'Define environment'
opts.on('-e', '--environment ENVIRONMENT', note) do |environment|
@environment = environment
end
opts.on('-d', '--detached', 'Run processor detached as a daemon') do
@detached = true
end
note = 'Define configuration file'
opts.on('-c', '--config CONFIG', note) do |config|
@config_file = config
|
ruby
|
{
"resource": ""
}
|
q25770
|
EventHub.Configuration.load!
|
validation
|
def load!(args = {})
# for better rspec testing
@config_file = args[:config_file] if args[:config_file]
@environment = args[:environment] if args[:environment]
new_data = {}
begin
new_data = JSON.parse(File.read(@config_file), symbolize_names: true)
|
ruby
|
{
"resource": ""
}
|
q25771
|
Vidibus.Words.keywords
|
validation
|
def keywords(limit = 20)
@keywords ||= {}
@keywords[limit] ||= begin
list = []
count = 0
_stopwords = Vidibus::Words.stopwords(*locales)
for word in sort
clean = word.permalink.gsub('-','')
unless
|
ruby
|
{
"resource": ""
}
|
q25772
|
ONIX.Normaliser.next_tempfile
|
validation
|
def next_tempfile
p = nil
Tempfile.open("onix") do
|
ruby
|
{
"resource": ""
}
|
q25773
|
ONIX.Reader.each
|
validation
|
def each(&block)
@reader.each do |node|
if @reader.node_type == 1 && @reader.name == "Product"
str = @reader.outer_xml
if str.nil?
yield @product_klass.new
|
ruby
|
{
"resource": ""
}
|
q25774
|
ONIX.APAProduct.title
|
validation
|
def title
composite = product.titles.first
if composite.nil?
nil
else
|
ruby
|
{
"resource": ""
}
|
q25775
|
ONIX.APAProduct.title=
|
validation
|
def title=(str)
composite = product.titles.first
if composite.nil?
composite = ONIX::Title.new
composite.title_type = 1
|
ruby
|
{
"resource": ""
}
|
q25776
|
ONIX.APAProduct.subtitle=
|
validation
|
def subtitle=(str)
composite = product.titles.first
if composite.nil?
composite = ONIX::Title.new
composite.title_type = 1
|
ruby
|
{
"resource": ""
}
|
q25777
|
ONIX.APAProduct.bic_subjects
|
validation
|
def bic_subjects
subjects = product.subjects.select { |sub| sub.subject_scheme_id.to_i == 12 }
|
ruby
|
{
"resource": ""
}
|
q25778
|
ONIX.APAProduct.imprint=
|
validation
|
def imprint=(str)
composite = product.imprints.first
if composite.nil?
composite = ONIX::Imprint.new
|
ruby
|
{
"resource": ""
}
|
q25779
|
ONIX.APAProduct.sales_restriction_type=
|
validation
|
def sales_restriction_type=(type)
composite = product.sales_restrictions.first
if composite.nil?
composite = ONIX::SalesRestriction.new
|
ruby
|
{
"resource": ""
}
|
q25780
|
ONIX.APAProduct.on_order
|
validation
|
def on_order
supply = find_or_create_supply_detail
composite = supply.stock.first
if composite.nil?
composite =
|
ruby
|
{
"resource": ""
}
|
q25781
|
ONIX.APAProduct.proprietry_discount_code_for_rrp
|
validation
|
def proprietry_discount_code_for_rrp
price = price_get(2)
return nil if price.nil?
discount =
|
ruby
|
{
"resource": ""
}
|
q25782
|
ONIX.APAProduct.proprietry_discount_code_for_rrp=
|
validation
|
def proprietry_discount_code_for_rrp=(code)
price = price_get(2)
if price.nil?
self.rrp_inc_sales_tax = 0
price = price_get(2)
end
discount = price.discounts_coded.find { |disc| disc.discount_code_type == 2 }
if discount.nil?
|
ruby
|
{
"resource": ""
}
|
q25783
|
ONIX.APAProduct.add_subject
|
validation
|
def add_subject(str, type = "12")
subject = ::ONIX::Subject.new
subject.subject_scheme_id = type.to_i
|
ruby
|
{
"resource": ""
}
|
q25784
|
ONIX.APAProduct.measurement_set
|
validation
|
def measurement_set(type, value, unit)
measure = measurement(type)
# create a new isbn record if we need to
if measure.nil?
measure = ONIX::Measure.new
measure.measure_type_code = type
|
ruby
|
{
"resource": ""
}
|
q25785
|
ONIX.APAProduct.price_get
|
validation
|
def price_get(type)
supply = find_or_create_supply_detail
if type.nil?
supply.prices.first
else
|
ruby
|
{
"resource": ""
}
|
q25786
|
ONIX.APAProduct.price_set
|
validation
|
def price_set(type, num)
p = price_get(type)
# create a new isbn record if we need to
if p.nil?
supply = find_or_create_supply_detail
p = ONIX::Price.new
|
ruby
|
{
"resource": ""
}
|
q25787
|
ONIX.APAProduct.other_text_set
|
validation
|
def other_text_set(type, value)
text = other_text(type)
if text.nil?
text = ONIX::OtherText.new
text.text_type_code = type
|
ruby
|
{
"resource": ""
}
|
q25788
|
ONIX.APAProduct.website_set
|
validation
|
def website_set(type, value)
site = website(type)
# create a new website record if we need to
if site.nil?
site = ONIX::Website.new
|
ruby
|
{
"resource": ""
}
|
q25789
|
Popular.Popular.befriend
|
validation
|
def befriend new_friend
run_callbacks :befriend do
|
ruby
|
{
"resource": ""
}
|
q25790
|
Popular.Popular.befriend!
|
validation
|
def befriend! new_friend
run_callbacks :befriend do
|
ruby
|
{
"resource": ""
}
|
q25791
|
Popular.Popular.unfriend
|
validation
|
def unfriend friend
run_callbacks :unfriend do
friendships
.where( friend_type: friend.class.name )
|
ruby
|
{
"resource": ""
}
|
q25792
|
TimecopConsole.ControllerMethods.handle_timecop_offset
|
validation
|
def handle_timecop_offset
# Establish now
if session[TimecopConsole::SESSION_KEY_NAME].present?
Rails.logger.debug "[timecop-console] Time traveling to #{session[TimecopConsole::SESSION_KEY_NAME].to_s}"
Timecop.travel(session[TimecopConsole::SESSION_KEY_NAME])
else
Timecop.return
end
|
ruby
|
{
"resource": ""
}
|
q25793
|
CodeMetrics.StatsDirectories.default_app_directories
|
validation
|
def default_app_directories
StatDirectory.from_list([
%w(Controllers app/controllers),
%w(Helpers app/helpers),
%w(Models app/models),
%w(Mailers
|
ruby
|
{
"resource": ""
}
|
q25794
|
CodeMetrics.StatsDirectories.collect_directories
|
validation
|
def collect_directories(glob_pattern, file_pattern='')
Pathname.glob(glob_pattern).select{|f|
|
ruby
|
{
"resource": ""
}
|
q25795
|
Ws2812.Basic.[]=
|
validation
|
def []=(index, color)
if index.respond_to?(:to_a)
index.to_a.each do |i|
check_index(i)
ws2811_led_set(@channel, i, color.to_i)
end
else
|
ruby
|
{
"resource": ""
}
|
q25796
|
Ws2812.Basic.set
|
validation
|
def set(index, r, g, b)
check_index(index)
self[index]
|
ruby
|
{
"resource": ""
}
|
q25797
|
Ws2812.Basic.[]
|
validation
|
def [](index)
if index.respond_to?(:to_a)
index.to_a.map do |i|
check_index(i)
Color.from_i(ws2811_led_get(@channel,
|
ruby
|
{
"resource": ""
}
|
q25798
|
ChefFS.Config.format_path
|
validation
|
def format_path(entry)
server_path = entry.path
if base_path && server_path[0,base_path.length] == base_path
if server_path == base_path
return "."
elsif server_path[base_path.length,1] == "/"
return server_path[base_path.length + 1, server_path.length -
|
ruby
|
{
"resource": ""
}
|
q25799
|
ChefFS.FilePattern.exact_path
|
validation
|
def exact_path
return nil if has_double_star || exact_parts.any? { |part| part.nil? }
|
ruby
|
{
"resource": ""
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.