_id
stringlengths
2
6
title
stringlengths
9
130
partition
stringclasses
3 values
text
stringlengths
66
10.5k
language
stringclasses
1 value
meta_information
dict
q23700
RightScraper::Retrievers.CheckoutBase.retrieve
train
def retrieve raise RetrieverError.new("retriever is unavailable") unless available? updated = false explanation = '' if exists? @logger.operation(:updating) do # a retriever may be able to determine that the repo directory is # already pointing to the same commit as t...
ruby
{ "resource": "" }
q23701
RightScraper::Retrievers.CheckoutBase.size_limit_exceeded?
train
def size_limit_exceeded? if @max_bytes # note that Dir.glob ignores hidden directories (e.g. ".git") so the # size total correctly excludes those hidden contents that are not to # be uploaded after scrape. this may cause the on-disk directory size # to far exceed the upload size. ...
ruby
{ "resource": "" }
q23702
RightScraper::Resources.Cookbook.to_hash
train
def to_hash { repository: repository, resource_hash: resource_hash, # location of cookbook manifest in S3 metadata: ::JSON.dump(metadata), # pass as opaque JSON blob pos: pos } end
ruby
{ "resource": "" }
q23703
RightGit::Git.BranchCollection.current
train
def current lines = @repo.git_output(['symbolic-ref', 'HEAD'], :raise_on_failure => false).lines if lines.size == 1 line = lines.first.strip if (match = HEAD_REF.match(line)) @branches.detect { |b| b.fullname == match[1] } elsif line == NO_HEAD_REF nil en...
ruby
{ "resource": "" }
q23704
RightGit::Git.BranchCollection.merged
train
def merged(revision) # By hand, build a list of all branches known to be merged into master git_args = ['branch', '-a', '--merged', revision] all_merged = [] @repo.git_output(git_args).lines.each do |line| line.strip! all_merged << Branch.new(@repo, line) end # Filte...
ruby
{ "resource": "" }
q23705
RightGit::Git.BranchCollection.[]
train
def [](argument) case argument when String target = Branch.new(@repo, argument) @branches.detect { |b| b == target } else @branches.__send__(:[], argument) end end
ruby
{ "resource": "" }
q23706
RightGit::Git.BranchCollection.method_missing
train
def method_missing(meth, *args, &block) result = @branches.__send__(meth, *args, &block) if result.is_a?(::Array) BranchCollection.new(@repo, result) else result end end
ruby
{ "resource": "" }
q23707
RightScraper::Scanners.CookbookS3Upload.notice
train
def notice(relative_position) contents = yield name = Digest::MD5.hexdigest(contents) path = File.join('Files', name) unless @bucket.key(path).exists? @bucket.put(path, contents) end end
ruby
{ "resource": "" }
q23708
Vic.Color.to_gui
train
def to_gui return to_standard_hex if hexadecimal? return Convert.xterm_to_hex(@value) if cterm? return :NONE if none? raise ColorError.new "can't convert \"#{ @value }\" to gui" end
ruby
{ "resource": "" }
q23709
Vic.Color.to_cterm
train
def to_cterm return @value if cterm? return Convert.hex_to_xterm(to_standard_hex) if hexadecimal? return :NONE if none? raise ColorError.new "can't convert \"#{ @value }\" to cterm" end
ruby
{ "resource": "" }
q23710
Vic.Color.to_standard_hex
train
def to_standard_hex color = @value.dup color.insert(0, '#') unless color.start_with? '#' # Convert shorthand hex to standard hex. if color.size == 4 color.slice!(1, 3).chars { |char| color << char * 2 } end color end
ruby
{ "resource": "" }
q23711
RightScraper::Retrievers.Svn.resolve_revision
train
def resolve_revision revision = @repository.tag.to_s.strip if revision.empty? revision = nil elsif (revision =~ SVN_REVISION_REGEX).nil? raise RetrieverError, "Revision reference contained illegal characters: #{revision.inspect}" end # timestamps can contain spaces; surroun...
ruby
{ "resource": "" }
q23712
BioTCM.Table.row_keys=
train
def row_keys=(val) raise ArgumentError, 'Illegal agrument type' unless val.is_a?(Array) raise ArgumentError, 'Unmatched size' if val.size < @row_keys.size @row_keys = val.map.with_index { |v, i| [v, i] }.to_h end
ruby
{ "resource": "" }
q23713
BioTCM.Table.ele
train
def ele(row, col, val = nil) if val.nil? get_ele(row, col) else set_ele(row, col, val) end end
ruby
{ "resource": "" }
q23714
BioTCM.Table.get_ele
train
def get_ele(row, col) row = @row_keys[row] col = @col_keys[col] row && col ? @content[row][col] : nil end
ruby
{ "resource": "" }
q23715
BioTCM.Table.set_ele
train
def set_ele(row, col, val) unless row.is_a?(String) && col.is_a?(String) && val.respond_to?(:to_s) raise ArgumentError, 'Illegal argument type' end set_row(row, [''] * @col_keys.size) unless @row_keys[row] set_col(col, [''] * @row_keys.size) unless @col_keys[col] row = @row_keys[...
ruby
{ "resource": "" }
q23716
BioTCM.Table.row
train
def row(row, val = nil) if val.nil? get_row(row) else set_row(row, val) end end
ruby
{ "resource": "" }
q23717
BioTCM.Table.get_row
train
def get_row(row) row = @row_keys[row] row.nil? ? nil : @col_keys.map { |c, ci| [c, @content[row][ci]] }.to_h end
ruby
{ "resource": "" }
q23718
BioTCM.Table.set_row
train
def set_row(row, val) # Setter if !row.is_a?(String) || (!val.is_a?(Hash) && !val.is_a?(Array)) raise ArgumentError, 'Illegal argument type' elsif val.is_a?(Array) && val.size != col_keys.size raise ArgumentError, 'Column size not match' end case val when Array ...
ruby
{ "resource": "" }
q23719
BioTCM.Table.col
train
def col(col, val = nil) if val.nil? get_col(col) else set_col(col, val) end end
ruby
{ "resource": "" }
q23720
BioTCM.Table.get_col
train
def get_col(col) col = @col_keys[col] col.nil? ? nil : @row_keys.map { |r, ri| [r, @content[ri][col]] }.to_h end
ruby
{ "resource": "" }
q23721
BioTCM.Table.set_col
train
def set_col(col, val) if !col.is_a?(String) || (!val.is_a?(Hash) && !val.is_a?(Array)) raise ArgumentError, 'Illegal argument type' elsif val.is_a?(Array) && val.size != row_keys.size raise ArgumentError, 'Row size not match' end case val when Array if @col_keys[co...
ruby
{ "resource": "" }
q23722
BioTCM.Table.each_row
train
def each_row if block_given? @row_keys.each_key { |r| yield(r, row(r)) } self else Enumerator.new do |y| @row_keys.each_key { |r| y << [r, row(r)] } end end end
ruby
{ "resource": "" }
q23723
BioTCM.Table.each_col
train
def each_col if block_given? @col_keys.each_key { |c| yield(c, col(c)) } self else Enumerator.new do |y| @col_keys.each_key { |c| y << [c, col(c)] } end end end
ruby
{ "resource": "" }
q23724
BioTCM::Databases::HGNC.Rescuer.rescue_symbol
train
def rescue_symbol(symbol, method = @rescue_method, rehearsal = false) return @rescue_history[symbol] if @rescue_history[symbol] case method when :auto auto_rescue = '' if @symbol2hgncid[symbol.upcase] auto_rescue = symbol.upcase elsif @symbol2hgncid[symbol.downcase]...
ruby
{ "resource": "" }
q23725
SeedFu.Seeder.seed_with_undo
train
def seed_with_undo if r = SeedFuNdo.recorder r.record self # return existing records in case they are processed by the caller @data.map { |record_data| find_record(record_data) } else seed_without_undo end end
ruby
{ "resource": "" }
q23726
Quantify.Dimensions.units
train
def units(by=nil) Unit.units.values.select { |unit| unit.dimensions == self }.map(&by).to_a end
ruby
{ "resource": "" }
q23727
Quantify.Dimensions.si_unit
train
def si_unit return Unit.steridian if describe == 'solid angle' return Unit.radian if describe == 'plane angle' val = si_base_units return nil unless val return val[0] if val.length == 1 val = val.inject(Unit.unity) do |compound,unit| compound * unit end val = ...
ruby
{ "resource": "" }
q23728
Quantify.Dimensions.si_base_units
train
def si_base_units(by=nil) val = self.to_hash.map do |dimension, index| dimension_name = dimension.remove_underscores Unit.base_quantity_si_units.select do |unit| unit.measures == dimension_name end.first.clone ** index end val = val.map(&by) if by val.to_a ...
ruby
{ "resource": "" }
q23729
Quantify.Dimensions.init_base_quantities
train
def init_base_quantities(options = { }) if options.has_key?(:physical_quantity) pq = options.delete(:physical_quantity) self.physical_quantity = pq.remove_underscores.downcase if pq end options.each_pair do |base_quantity, index| base_quantity = base_quantity.to_s.downcase.to_s...
ruby
{ "resource": "" }
q23730
Quantify.Quantity.to_s
train
def to_s format=:symbol if format == :name unit_string = @value == 1 || @value == -1 ? @unit.name : @unit.pluralized_name else unit_string = @unit.send format end string = "#{@value}" string += " #{unit_string}" unless unit_string.empty? string end
ruby
{ "resource": "" }
q23731
Quantify.Quantity.to_si
train
def to_si if @unit.is_compound_unit? Quantity.new(@value,@unit).convert_compound_unit_to_si! elsif @unit.is_dimensionless? return self.clone elsif @value.nil? return Quantity.new(nil, @unit.si_unit) else self.to(@unit.si_unit) end end
ruby
{ "resource": "" }
q23732
Vic.ColorScheme.highlight!
train
def highlight!(group, attributes={}) highlight(group, attributes.dup.tap { |hash| hash[:force] = true }) end
ruby
{ "resource": "" }
q23733
Vic.ColorScheme.link
train
def link(*from_groups, to_group) from_groups.flatten.map do |from_group| # Don't add anything we don't already have. next if find_link(from_group, to_group) link = Link.new(from_group, to_group) link.tap { |l| @links << l } end.compact end
ruby
{ "resource": "" }
q23734
Vic.ColorScheme.link!
train
def link!(*from_groups, to_group) # Use the default method first. self.link(from_groups, to_group) # Then update the links. from_groups.flatten.map do |from_group| link = find_link(from_group, to_group) link.tap(&:force!) end end
ruby
{ "resource": "" }
q23735
Vic.ColorScheme.language
train
def language(name = nil, &block) return @language unless name and block_given? previous_language = self.language @language = name block.arity == 0 ? instance_eval(&block) : yield(self) @language = previous_language end
ruby
{ "resource": "" }
q23736
RightScraper::Scanners.CookbookMetadataReadOnly.generated_metadata_json_readonly
train
def generated_metadata_json_readonly @logger.operation(:metadata_readonly) do # path constants freed_metadata_dir = (@cookbook.pos == '.' && freed_dir) || ::File.join(freed_dir, @cookbook.pos) freed_metadata_json_path = ::File.join(freed_metadata_dir, JSON_METADATA) # in the multi...
ruby
{ "resource": "" }
q23737
BioTCM.Layer.save
train
def save(path, prefix = '') FileUtils.mkdir_p(path) @edge_tab.save(File.expand_path(prefix + 'edges.tab', path)) @node_tab.save(File.expand_path(prefix + 'nodes.tab', path)) end
ruby
{ "resource": "" }
q23738
RightScraper.Main.scrape
train
def scrape(repo, incremental=true, &callback) old_logger_callback = @logger.callback @logger.callback = callback errorlen = errors.size begin if retrieved = retrieve(repo) scan(retrieved) end rescue Exception # legacy logger handles communication with the ...
ruby
{ "resource": "" }
q23739
RightScraper::Retrievers.Download.retrieve
train
def retrieve raise RetrieverError.new("download retriever is unavailable") unless available? ::FileUtils.remove_entry_secure @repo_dir if File.exists?(@repo_dir) ::FileUtils.remove_entry_secure workdir if File.exists?(workdir) ::FileUtils.mkdir_p @repo_dir ::FileUtils.mkdir_p workdir ...
ruby
{ "resource": "" }
q23740
Cadmus.Renderable.setup_renderer
train
def setup_renderer(renderer) renderer.default_assigns = liquid_assigns if respond_to?(:liquid_assigns, true) renderer.default_registers = liquid_registers if respond_to?(:liquid_registers, true) renderer.default_filters = liquid_filters if respond_to?(:liquid_filters, true) end
ruby
{ "resource": "" }
q23741
Spectus.ExpectationTarget.MUST
train
def MUST(m) RequirementLevel::High.new(m, false, subject, *challenges).result end
ruby
{ "resource": "" }
q23742
Spectus.ExpectationTarget.MUST_NOT
train
def MUST_NOT(m) RequirementLevel::High.new(m, true, subject, *challenges).result end
ruby
{ "resource": "" }
q23743
Spectus.ExpectationTarget.SHOULD
train
def SHOULD(m) RequirementLevel::Medium.new(m, false, subject, *challenges).result end
ruby
{ "resource": "" }
q23744
Spectus.ExpectationTarget.SHOULD_NOT
train
def SHOULD_NOT(m) RequirementLevel::Medium.new(m, true, subject, *challenges).result end
ruby
{ "resource": "" }
q23745
RightScraper::Scrapers.Cookbook.find_next
train
def find_next(dir) @logger.operation(:finding_next_cookbook, "in #{dir.path}") do if COOKBOOK_SENTINELS.any? { |f| File.exists?(File.join(dir.path, f)) } @logger.operation(:reading_cookbook, "from #{dir.path}") do cookbook = RightScraper::Resources::Cookbook.new( @repos...
ruby
{ "resource": "" }
q23746
RightScraper::Scrapers.Base.search_dirs
train
def search_dirs @logger.operation(:searching) do until @stack.empty? dir = @stack.last entry = dir.read if entry == nil dir.close @stack.pop next end next if entry == '.' || entry == '..' next if ignorable?(en...
ruby
{ "resource": "" }
q23747
RightScraper::Scanners.Union.notice
train
def notice(relative_position) data = nil @subscanners.each {|scanner| scanner.notice(relative_position) { data = yield if data.nil? data } } end
ruby
{ "resource": "" }
q23748
RightScraper.SpecHelpers.create_file_layout
train
def create_file_layout(path, layout) FileUtils.mkdir_p(path) result = [] layout.each do |elem| if elem.is_a?(Hash) elem.each do |k, v| full_path = File.join(path, k) FileUtils.mkdir_p(full_path) result += create_file_layout(full_path, v) ...
ruby
{ "resource": "" }
q23749
RightScraper.SpecHelpers.extract_file_layout
train
def extract_file_layout(path, ignore=[]) return [] unless File.directory?(path) dirs = [] files = [] ignore += [ '.', '..' ] Dir.foreach(path) do |f| next if ignore.include?(f) full_path = File.join(path, f) if File.directory?(full_path) dirs << { f => ext...
ruby
{ "resource": "" }
q23750
RightScraper::Repositories.Base.equal_repo?
train
def equal_repo?(other) if other.is_a?(RightScraper::Repositories::Base) repository_hash == other.repository_hash else false end end
ruby
{ "resource": "" }
q23751
RightScraper::Repositories.Base.add_users_to
train
def add_users_to(uri, username=nil, password=nil) begin uri = URI.parse(uri) if uri.instance_of?(String) if username userinfo = URI.escape(username, USERPW) userinfo += ":" + URI.escape(password, USERPW) unless password.nil? uri.userinfo = userinfo end ...
ruby
{ "resource": "" }
q23752
Canis.KeyDispatcher.process_key
train
def process_key ch chr = nil if ch > 0 and ch < 256 chr = ch.chr end return :UNHANDLED unless @key_map @key_map.each_pair do |k,p| #$log.debug "KKK: processing key #{ch} #{chr} " if (k == ch || k == chr) #$log.debug "KKK: checking match == #{k}: #{ch} ...
ruby
{ "resource": "" }
q23753
Canis.KeyDispatcher.default_string_key_map
train
def default_string_key_map require 'canis/core/include/action' @key_map ||= {} @key_map[ Regexp.new('[a-zA-Z0-9_\.\/]') ] = Action.new("Append to pattern") { |obj, ch| obj.buffer << ch.chr obj.buffer_changed } @key_map[ [127, ?\C-h.getbyte(0)] ] = Action.new("Delete Prev Ch...
ruby
{ "resource": "" }
q23754
Canis.CommandWindow.press
train
def press ch ch = ch.getbyte(0) if ch.class==String ## 1.9 $log.debug " XXX press #{ch} " if $log.debug? case ch when -1 return when KEY_F1, 27, ?\C-q.getbyte(0) @stop = true return when KEY_ENTER, 10, 13 #$log.debug "popup ENTER : #{@selected_ind...
ruby
{ "resource": "" }
q23755
Canis.CommandWindow.configure
train
def configure(*val , &block) case val.size when 1 return @config[val[0]] when 2 @config[val[0]] = val[1] instance_variable_set("@#{val[0]}", val[1]) end instance_eval &block if block_given? end
ruby
{ "resource": "" }
q23756
Canis.ControlPHandler.recursive_search
train
def recursive_search glob="**/*" @command = Proc.new {|str| Dir.glob(glob).select do |p| p.index str; end } end
ruby
{ "resource": "" }
q23757
Canis.ControlPHandler.data_changed
train
def data_changed list sz = list.size @source.text(list) wh = @source.form.window.height @source.form.window.hide th = @source.height sh = Ncurses.LINES-1 if sz < @maxht # rows is less than tp size so reduce tp and window @source.height = sz nl = _new_lay...
ruby
{ "resource": "" }
q23758
Canis.ControlPHandler.buffer_changed
train
def buffer_changed # display the pattern on the header @header.text1(">>>#{@buffer}_") if @header @header.text_right(Dir.pwd) if @header @no_match = false if @command @list = @command.call(@buffer) else @list = @__list.select do |line| line.index @buffer ...
ruby
{ "resource": "" }
q23759
Canis.ControlPHandler.handle_key
train
def handle_key ch $log.debug " HANDLER GOT KEY #{ch} " @keyint = ch @keychr = nil # accumulate keys in a string # need to track insertion point if user uses left and right arrow @buffer ||= "" chr = nil chr = ch.chr if ch > 47 and ch < 127 @keychr = chr ...
ruby
{ "resource": "" }
q23760
Canis.ControlPHandler.default_key_map
train
def default_key_map tp = source source.bind_key(?\M-n.getbyte(0), 'goto_end'){ tp.goto_end } source.bind_key(?\M-p.getbyte(0), 'goto_start'){ tp.goto_start } end
ruby
{ "resource": "" }
q23761
Canis.ControlPHandler.directory_key_map
train
def directory_key_map @key_map["<"] = Action.new("Goto Parent Dir") { |obj| # go to parent dir $log.debug "KKK: called proc for <" Dir.chdir("..") obj.buffer_changed } @key_map[">"] = Action.new("Change Dir"){ |obj| $log.debug "KKK: called proc for > : #{obj.c...
ruby
{ "resource": "" }
q23762
Canis.BorderTitle.print_borders
train
def print_borders bordertitle_init unless @_bordertitle_init_called raise ArgumentError, "Graphic not set" unless @graphic raise "#{self} needs width" unless @width raise "#{self} needs height" unless @height width = @width height = @height-1 window = @graphic startcol = ...
ruby
{ "resource": "" }
q23763
Canis.List.list
train
def list *val return @list if val.empty? alist = val[0] case alist when Array @list = alist # I possibly should call init_vars in these 3 cases but am doing the minimal 2013-04-10 - 18:27 # Based no issue: https://github.com/mare-imbrium/canis/issues/15 @current_...
ruby
{ "resource": "" }
q23764
Canis.List.ask_search_backward
train
def ask_search_backward regex = get_string("Enter regex to search (backward)") @last_regex = regex ix = @list.find_prev regex, @current_index if ix.nil? alert("No matching data for: #{regex}") else set_focus_on(ix) end end
ruby
{ "resource": "" }
q23765
Canis.List.repaint
train
def repaint #:nodoc: return unless @repaint_required # # TRYING OUT dangerous 2011-10-15 @repaint_required = false @repaint_required = true if @widget_scrolled || @pcol != @old_pcol || @record_changed || @property_changed unless @repaint_required unhighlight_row @old_select...
ruby
{ "resource": "" }
q23766
Canis.List.sanitize
train
def sanitize content #:nodoc: if content.is_a? String content.chomp! content.gsub!(/\t/, ' ') # don't display tab content.gsub!(/[^[:print:]]/, '') # don't display non print characters else content end end
ruby
{ "resource": "" }
q23767
Canis.List.init_actions
train
def init_actions am = action_manager() am.add_action(Action.new("&Disable selection") { @selection_mode = :none; unbind_key(32); bind_key(32, :scroll_forward); } ) am.add_action(Action.new("&Edit Toggle") { @edit_toggle = !@edit_toggle; $status_message.value = "Edit toggle is #{@edit_toggle}" }) e...
ruby
{ "resource": "" }
q23768
Canis.Box.repaint
train
def repaint return unless @repaint_required bc = $datacolor bordercolor = @border_color || bc borderatt = @border_attrib || Ncurses::A_NORMAL @window.print_border row, col, height, width, bordercolor, borderatt #print_borders print_title @repaint_required = false end
ruby
{ "resource": "" }
q23769
Canis.WidgetShortcuts.dock
train
def dock labels, config={}, &block require 'canis/core/widgets/keylabelprinter' klp = Canis::KeyLabelPrinter.new @form, labels, config, &block end
ruby
{ "resource": "" }
q23770
Canis.WidgetShortcuts.status_line
train
def status_line config={}, &block require 'canis/core/widgets/statusline' sl = Canis::StatusLine.new @form, config, &block end
ruby
{ "resource": "" }
q23771
Canis.WidgetShortcuts.table
train
def table config={}, &block #def tabular_widget config={}, &block require 'canis/core/widgets/table' events = [:PROPERTY_CHANGE, :LEAVE, :ENTER, :CHANGE, :ENTER_ROW, :PRESS ] block_event = nil # if no width given, expand to stack width #config.delete :title useform = nil w...
ruby
{ "resource": "" }
q23772
Canis.WidgetShortcuts._configure
train
def _configure s s[:row] ||= 0 s[:col] ||= 0 s[:row] += (s[:margin_top] || 0) s[:col] += (s[:margin_left] || 0) s[:width] = FFI::NCurses.COLS-s[:col] if s[:width] == :expand s[:height] = FFI::NCurses.LINES-s[:row] if s[:height] == :expand # 2011-11-30 last = @_ws_active.last ...
ruby
{ "resource": "" }
q23773
KnifeCloudstack.CsServerCreate.is_ssh_open?
train
def is_ssh_open?(ip) s = Socket.new(Socket::AF_INET, Socket::SOCK_STREAM, 0) sa = Socket.sockaddr_in(locate_config_value(:ssh_port), ip) begin s.connect_nonblock(sa) rescue Errno::EINPROGRESS resp = IO.select(nil, [s], nil, 1) if resp.nil? sleep SSH_POLL_INTERV...
ruby
{ "resource": "" }
q23774
Cream.UserControl.sign_in
train
def sign_in(resource_or_scope, *args) options = args.extract_options! scope = Devise::Mapping.find_scope!(resource_or_scope) resource = args.last || resource_or_scope expire_session_data_after_sign_in! warden.set_user(resource, options.merge!(:scope => scope)) # set user id ...
ruby
{ "resource": "" }
q23775
Cream.UserControl.sign_out
train
def sign_out(resource_or_scope) scope = Devise::Mapping.find_scope!(resource_or_scope) warden.user(scope) # Without loading user here, before_logout hook is not called warden.raw_session.inspect # Without this inspect here. The session does not clear. warden.logout(scope) # user id ...
ruby
{ "resource": "" }
q23776
Canis.TextArea.insert
train
def insert off0, data _maxlen = @maxlen || @width - @internal_width if data.length > _maxlen data = wrap_text data # $log.debug "after wrap text done :#{data}" data = data.split("\n") data[-1] << "\r" #XXXX data.each do |row| @list.insert off0, row off0 ...
ruby
{ "resource": "" }
q23777
Canis.TextArea.<<
train
def << data # if width if nil, either set it, or add this to a container that sets it before calling this method _maxlen = @maxlen || @width - @internal_width if data.length > _maxlen #$log.debug "wrapped append for #{data}" data = wrap_text data #$log.debug "after wrap text fo...
ruby
{ "resource": "" }
q23778
Canis.TextArea.undo_delete
train
def undo_delete # added 2008-11-27 12:43 paste delete buffer into insertion point return if @delete_buffer.nil? $log.warn "undo_delete is broken! perhaps cannot be used . textarea 347 " # FIXME - can be an array case @delete_buffer when Array # we need to unrol...
ruby
{ "resource": "" }
q23779
Canis.TextArea.insert_break
train
def insert_break return -1 unless @editable # insert a blank row and append rest of this line to cursor $log.debug "ENTER PRESSED at #{@curpos}, on row #{@current_index}" @delete_buffer = (delete_eol || "") @list[@current_index] << "\r" $log.debug "DELETE BUFFER #{@delete_buffer}" ...
ruby
{ "resource": "" }
q23780
Canis.TextArea.set_form_col
train
def set_form_col col1=@curpos @curpos = col1 @cols_panned ||= 0 cursor_bounds_check ## added win_col on 2009-12-28 20:21 for embedded forms BUFFERED TRYING OUT win_col = 0 # 2010-02-07 23:19 new cursor stuff #col = win_col + @orig_col + @col_offset + @curpos #col = win_c...
ruby
{ "resource": "" }
q23781
Canis.TextArea.insert_wrap
train
def insert_wrap lineno, pos, lastchars _maxlen = @maxlen || @width - @internal_width @list[lineno].insert pos, lastchars len = @list[lineno].length if len > _maxlen push_last_word lineno #- sometime i may push down 10 chars but the last word is less end end
ruby
{ "resource": "" }
q23782
Canis.TextArea.putch
train
def putch char _maxlen = @maxlen || @width - @internal_width @buffer ||= @list[@current_index] return -1 if !@editable #or @buffer.length >= _maxlen #if @chars_allowed != nil # remove useless functionality #return if char.match(@chars_allowed).nil? #end raise "putch expects ...
ruby
{ "resource": "" }
q23783
Canis.TextArea.remove_last_word
train
def remove_last_word lineno @list[lineno].chomp! line=@list[lineno] lastspace = line.rindex(" ") if !lastspace.nil? lastchars = line[lastspace+1..-1] @list[lineno].slice!(lastspace..-1) $log.debug " remove_last: lastspace #{lastspace},#{lastchars},#{@list[lineno]}" ...
ruby
{ "resource": "" }
q23784
Canis.TextArea.move_chars_up
train
def move_chars_up oldprow = @current_index oldcurpos = @curpos _maxlen = @maxlen || @width - @internal_width space_left = _maxlen - @buffer.length can_move = [space_left, next_line.length].min carry_up = @list[@current_index+1].slice!(0, can_move) @list[@current_index] << car...
ruby
{ "resource": "" }
q23785
Canis.TextArea.get_text
train
def get_text l = getvalue str = "" old = " " l.each_with_index do |line, i| tmp = line.gsub("\n","") tmp.gsub!("\r", "\n") if old[-1,1] !~ /\s/ and tmp[0,1] !~ /\s/ str << " " end str << tmp old = tmp end str end
ruby
{ "resource": "" }
q23786
Canis.Tree.root
train
def root node=nil, asks_allow_children=false, &block if @treemodel return @treemodel.root unless node raise ArgumentError, "Root already set" end raise ArgumentError, "root: node cannot be nil" unless node @treemodel = Canis::DefaultTreeModel.new(node, asks_allow_children, &bloc...
ruby
{ "resource": "" }
q23787
Canis.Tree.select_default_values
train
def select_default_values return if @default_value.nil? # NOTE list not yet created raise "list has not yet been created" unless @list index = node_to_row @default_value raise "could not find node #{@default_value}, #{@list} " unless index return unless index @current_index = ...
ruby
{ "resource": "" }
q23788
Canis.Tree.node_to_row
train
def node_to_row node crow = nil @list.each_with_index { |e,i| if e == node crow = i break end } crow end
ruby
{ "resource": "" }
q23789
Canis.Tree.expand_parents
train
def expand_parents node _path = node.tree_path _path.each do |e| # if already expanded parent then break we should break #set_expanded_state(e, true) expand_node(e) end end
ruby
{ "resource": "" }
q23790
Canis.Tree.expand_children
train
def expand_children node=:current_index $multiplier = 999 if !$multiplier || $multiplier == 0 node = row_to_node if node == :current_index return if node.children.empty? # or node.is_leaf? #node.children.each do |e| #expand_node e # this will keep expanding parents #expand_child...
ruby
{ "resource": "" }
q23791
Canis.DefaultTableRowSorter.sort
train
def sort return unless @model return if @sort_keys.empty? $log.debug "TABULAR SORT KEYS #{sort_keys} " # first row is the header which should remain in place # We could have kept column headers separate, but then too much of mucking around # with textpad, this way we avoi...
ruby
{ "resource": "" }
q23792
Canis.DefaultTableRowSorter.toggle_sort_order
train
def toggle_sort_order index index += 1 # increase by 1, since 0 won't multiple by -1 # internally, reverse sort is maintained by multiplying number by -1 @sort_keys ||= [] if @sort_keys.first && index == @sort_keys.first.abs @sort_keys[0] *= -1 else @sort_keys...
ruby
{ "resource": "" }
q23793
Canis.DefaultTableRenderer.convert_value_to_text
train
def convert_value_to_text r str = [] fmt = nil field = nil # we need to loop through chash and get index from it and get that row from r each_column {|c,i| e = r[c.index] w = c.width l = e.to_s.length # if value is longer than width, then t...
ruby
{ "resource": "" }
q23794
Canis.DefaultTableRenderer.render_data
train
def render_data pad, lineno, text text = text.join # FIXME why repeatedly getting this colorpair cp = @color_pair att = @attrib # added for selection, but will crash if selection is not extended !!! XXX if @source.is_row_selected? lineno att = REVERSE ...
ruby
{ "resource": "" }
q23795
Canis.DefaultTableRenderer.check_colors
train
def check_colors each_column {|c,i| if c.color || c.bgcolor || c.attrib @_check_coloring = true return end @_check_coloring = false } end
ruby
{ "resource": "" }
q23796
Canis.Table.get_column
train
def get_column index return @chash[index] if @chash[index] # create a new entry since none present c = ColumnInfo.new c.index = index @chash[index] = c return c end
ruby
{ "resource": "" }
q23797
Canis.Table.content_cols
train
def content_cols total = 0 #@chash.each_pair { |i, c| #@chash.each_with_index { |c, i| #next if c.hidden each_column {|c,i| w = c.width # if you use prepare_format then use w+2 due to separator symbol total += w + 1 } return total end
ruby
{ "resource": "" }
q23798
Canis.Table.fire_column_event
train
def fire_column_event eve require 'canis/core/include/ractionevent' aev = TextActionEvent.new self, eve, get_column(@column_pointer.current_index), @column_pointer.current_index, @column_pointer.last_index fire_handler eve, aev end
ruby
{ "resource": "" }
q23799
Canis.Table._init_model
train
def _init_model array # clear the column data -- this line should be called otherwise previous tables stuff will remain. @chash.clear array.each_with_index { |e,i| # if columns added later we could be overwriting the width c = get_column(i) c.width ||= 10 } # mainta...
ruby
{ "resource": "" }