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
mongodb/bson-ruby
lib/bson/object_id.rb
BSON.ObjectId.to_bson
def to_bson(buffer = ByteBuffer.new, validating_keys = Config.validating_keys?) buffer.put_bytes(generate_data) end
ruby
def to_bson(buffer = ByteBuffer.new, validating_keys = Config.validating_keys?) buffer.put_bytes(generate_data) end
[ "def", "to_bson", "(", "buffer", "=", "ByteBuffer", ".", "new", ",", "validating_keys", "=", "Config", ".", "validating_keys?", ")", "buffer", ".", "put_bytes", "(", "generate_data", ")", "end" ]
Get the object id as it's raw BSON data. @example Get the raw bson bytes. object_id.to_bson @note Since Moped's BSON and MongoDB BSON before 2.0.0 have different internal representations, we will attempt to repair the data for cases where the object was instantiated in a non-standard way. (Like a Marshal.load) @return [ BSON::ByteBuffer ] The buffer with the encoded object. @see http://bsonspec.org/#/specification @since 2.0.0
[ "Get", "the", "object", "id", "as", "it", "s", "raw", "BSON", "data", "." ]
297af124a7462f522b75fe9851ac81ce4fd33b0f
https://github.com/mongodb/bson-ruby/blob/297af124a7462f522b75fe9851ac81ce4fd33b0f/lib/bson/object_id.rb#L172-L174
train
mongodb/bson-ruby
lib/bson/true_class.rb
BSON.TrueClass.to_bson
def to_bson(buffer = ByteBuffer.new, validating_keys = Config.validating_keys?) buffer.put_byte(TRUE_BYTE) end
ruby
def to_bson(buffer = ByteBuffer.new, validating_keys = Config.validating_keys?) buffer.put_byte(TRUE_BYTE) end
[ "def", "to_bson", "(", "buffer", "=", "ByteBuffer", ".", "new", ",", "validating_keys", "=", "Config", ".", "validating_keys?", ")", "buffer", ".", "put_byte", "(", "TRUE_BYTE", ")", "end" ]
Get the true boolean as encoded BSON. @example Get the true boolean as encoded BSON. true.to_bson @return [ BSON::ByteBuffer ] The buffer with the encoded object. @see http://bsonspec.org/#/specification @since 2.0.0
[ "Get", "the", "true", "boolean", "as", "encoded", "BSON", "." ]
297af124a7462f522b75fe9851ac81ce4fd33b0f
https://github.com/mongodb/bson-ruby/blob/297af124a7462f522b75fe9851ac81ce4fd33b0f/lib/bson/true_class.rb#L52-L54
train
mongodb/bson-ruby
lib/bson/binary.rb
BSON.Binary.to_bson
def to_bson(buffer = ByteBuffer.new, validating_keys = Config.validating_keys?) position = buffer.length buffer.put_int32(0) buffer.put_byte(SUBTYPES[type]) buffer.put_int32(data.bytesize) if type == :old buffer.put_bytes(data.force_encoding(BINARY)) buffer.replace_int32(position, buffer.length - position - 5) end
ruby
def to_bson(buffer = ByteBuffer.new, validating_keys = Config.validating_keys?) position = buffer.length buffer.put_int32(0) buffer.put_byte(SUBTYPES[type]) buffer.put_int32(data.bytesize) if type == :old buffer.put_bytes(data.force_encoding(BINARY)) buffer.replace_int32(position, buffer.length - position - 5) end
[ "def", "to_bson", "(", "buffer", "=", "ByteBuffer", ".", "new", ",", "validating_keys", "=", "Config", ".", "validating_keys?", ")", "position", "=", "buffer", ".", "length", "buffer", ".", "put_int32", "(", "0", ")", "buffer", ".", "put_byte", "(", "SUBTYPES", "[", "type", "]", ")", "buffer", ".", "put_int32", "(", "data", ".", "bytesize", ")", "if", "type", "==", ":old", "buffer", ".", "put_bytes", "(", "data", ".", "force_encoding", "(", "BINARY", ")", ")", "buffer", ".", "replace_int32", "(", "position", ",", "buffer", ".", "length", "-", "position", "-", "5", ")", "end" ]
Encode the binary type @example Encode the binary. binary.to_bson @return [ BSON::ByteBuffer ] The buffer with the encoded object. @see http://bsonspec.org/#/specification @since 2.0.0
[ "Encode", "the", "binary", "type" ]
297af124a7462f522b75fe9851ac81ce4fd33b0f
https://github.com/mongodb/bson-ruby/blob/297af124a7462f522b75fe9851ac81ce4fd33b0f/lib/bson/binary.rb#L134-L141
train
mongodb/bson-ruby
lib/bson/registry.rb
BSON.Registry.get
def get(byte, field = nil) if type = MAPPINGS[byte] || (byte.is_a?(String) && type = MAPPINGS[byte.ord]) type else handle_unsupported_type!(byte, field) end end
ruby
def get(byte, field = nil) if type = MAPPINGS[byte] || (byte.is_a?(String) && type = MAPPINGS[byte.ord]) type else handle_unsupported_type!(byte, field) end end
[ "def", "get", "(", "byte", ",", "field", "=", "nil", ")", "if", "type", "=", "MAPPINGS", "[", "byte", "]", "||", "(", "byte", ".", "is_a?", "(", "String", ")", "&&", "type", "=", "MAPPINGS", "[", "byte", ".", "ord", "]", ")", "type", "else", "handle_unsupported_type!", "(", "byte", ",", "field", ")", "end", "end" ]
Get the class for the single byte identifier for the type in the BSON specification. @example Get the type for the byte. BSON::Registry.get("\x01") @return [ Class ] The corresponding Ruby class for the type. @see http://bsonspec.org/#/specification @since 2.0.0
[ "Get", "the", "class", "for", "the", "single", "byte", "identifier", "for", "the", "type", "in", "the", "BSON", "specification", "." ]
297af124a7462f522b75fe9851ac81ce4fd33b0f
https://github.com/mongodb/bson-ruby/blob/297af124a7462f522b75fe9851ac81ce4fd33b0f/lib/bson/registry.rb#L42-L48
train
mongodb/bson-ruby
lib/bson/date.rb
BSON.Date.to_bson
def to_bson(buffer = ByteBuffer.new, validating_keys = Config.validating_keys?) buffer.put_int64((jd - DATE_REFERENCE) * MILLISECONDS_IN_DAY) end
ruby
def to_bson(buffer = ByteBuffer.new, validating_keys = Config.validating_keys?) buffer.put_int64((jd - DATE_REFERENCE) * MILLISECONDS_IN_DAY) end
[ "def", "to_bson", "(", "buffer", "=", "ByteBuffer", ".", "new", ",", "validating_keys", "=", "Config", ".", "validating_keys?", ")", "buffer", ".", "put_int64", "(", "(", "jd", "-", "DATE_REFERENCE", ")", "*", "MILLISECONDS_IN_DAY", ")", "end" ]
Get the date as encoded BSON. @example Get the date as encoded BSON. Date.new(2012, 1, 1).to_bson @return [ BSON::ByteBuffer ] The buffer with the encoded object. @see http://bsonspec.org/#/specification @since 2.1.0
[ "Get", "the", "date", "as", "encoded", "BSON", "." ]
297af124a7462f522b75fe9851ac81ce4fd33b0f
https://github.com/mongodb/bson-ruby/blob/297af124a7462f522b75fe9851ac81ce4fd33b0f/lib/bson/date.rb#L47-L49
train
mongodb/bson-ruby
lib/bson/regexp.rb
BSON.Regexp.to_bson
def to_bson(buffer = ByteBuffer.new, validating_keys = Config.validating_keys?) buffer.put_cstring(source) buffer.put_cstring(bson_options) end
ruby
def to_bson(buffer = ByteBuffer.new, validating_keys = Config.validating_keys?) buffer.put_cstring(source) buffer.put_cstring(bson_options) end
[ "def", "to_bson", "(", "buffer", "=", "ByteBuffer", ".", "new", ",", "validating_keys", "=", "Config", ".", "validating_keys?", ")", "buffer", ".", "put_cstring", "(", "source", ")", "buffer", ".", "put_cstring", "(", "bson_options", ")", "end" ]
Get the regular expression as encoded BSON. @example Get the regular expression as encoded BSON. %r{\d+}.to_bson @note From the BSON spec: The first cstring is the regex pattern, the second is the regex options string. Options are identified by characters, which must be stored in alphabetical order. Valid options are 'i' for case insensitive matching, 'm' for multiline matching, 'x' for verbose mode, 'l' to make \w, \W, etc. locale dependent, 's' for dotall mode ('.' matches everything), and 'u' to make \w, \W, etc. match unicode. @param [ BSON::ByteBuffer ] buffer The byte buffer to append to. @param [ true, false ] validating_keys @return [ BSON::ByteBuffer ] The buffer with the encoded object. @see http://bsonspec.org/#/specification @since 2.0.0
[ "Get", "the", "regular", "expression", "as", "encoded", "BSON", "." ]
297af124a7462f522b75fe9851ac81ce4fd33b0f
https://github.com/mongodb/bson-ruby/blob/297af124a7462f522b75fe9851ac81ce4fd33b0f/lib/bson/regexp.rb#L92-L95
train
mongodb/bson-ruby
lib/bson/time.rb
BSON.Time.to_bson
def to_bson(buffer = ByteBuffer.new, validating_keys = Config.validating_keys?) buffer.put_int64((to_i * 1000) + (usec / 1000)) end
ruby
def to_bson(buffer = ByteBuffer.new, validating_keys = Config.validating_keys?) buffer.put_int64((to_i * 1000) + (usec / 1000)) end
[ "def", "to_bson", "(", "buffer", "=", "ByteBuffer", ".", "new", ",", "validating_keys", "=", "Config", ".", "validating_keys?", ")", "buffer", ".", "put_int64", "(", "(", "to_i", "*", "1000", ")", "+", "(", "usec", "/", "1000", ")", ")", "end" ]
Get the time as encoded BSON. @example Get the time as encoded BSON. Time.new(2012, 1, 1, 0, 0, 0).to_bson @return [ BSON::ByteBuffer ] The buffer with the encoded object. @see http://bsonspec.org/#/specification @since 2.0.0
[ "Get", "the", "time", "as", "encoded", "BSON", "." ]
297af124a7462f522b75fe9851ac81ce4fd33b0f
https://github.com/mongodb/bson-ruby/blob/297af124a7462f522b75fe9851ac81ce4fd33b0f/lib/bson/time.rb#L40-L42
train
mongodb/bson-ruby
lib/bson/document.rb
BSON.Document.fetch
def fetch(key, *args, &block) key = convert_key(key) super(key, *args, &block) end
ruby
def fetch(key, *args, &block) key = convert_key(key) super(key, *args, &block) end
[ "def", "fetch", "(", "key", ",", "*", "args", ",", "&", "block", ")", "key", "=", "convert_key", "(", "key", ")", "super", "(", "key", ",", "*", "args", ",", "&", "block", ")", "end" ]
Get a value from the document for the provided key. Can use string or symbol access, with string access being the faster of the two. @overload fetch(key) Returns a value from the hash for the given key. If the key does not exist, raises KeyError exception. @overload fetch(key, default) Returns a value from the hash for the given key. If the key does not exist, returns *default*. @overload fetch(key, &block) Returns a value from the hash for the given key. If the key does not exist, returns the value of the block called with the key. @example Get an element for the key. document.fetch("field") @example Get an element for the key by symbol with a default. document.fetch(:field, 'foo') @example Get an element for the key by symbol with a block default. document.fetch(:field) { |key| key.upcase } @param [ String, Symbol ] key The key to look up. @param [ Object ] default Returned value if key does not exist. @yield [key] Block returning default value for the given key. @return [ Object ] The found value. Raises KeyError if none found. @since 4.4.0
[ "Get", "a", "value", "from", "the", "document", "for", "the", "provided", "key", ".", "Can", "use", "string", "or", "symbol", "access", "with", "string", "access", "being", "the", "faster", "of", "the", "two", "." ]
297af124a7462f522b75fe9851ac81ce4fd33b0f
https://github.com/mongodb/bson-ruby/blob/297af124a7462f522b75fe9851ac81ce4fd33b0f/lib/bson/document.rb#L68-L71
train
mongodb/bson-ruby
lib/bson/document.rb
BSON.Document.merge!
def merge!(other) other.each_pair do |key, value| value = yield(convert_key(key), self[key], convert_value(value)) if block_given? && self[key] self[key] = value end self end
ruby
def merge!(other) other.each_pair do |key, value| value = yield(convert_key(key), self[key], convert_value(value)) if block_given? && self[key] self[key] = value end self end
[ "def", "merge!", "(", "other", ")", "other", ".", "each_pair", "do", "|", "key", ",", "value", "|", "value", "=", "yield", "(", "convert_key", "(", "key", ")", ",", "self", "[", "key", "]", ",", "convert_value", "(", "value", ")", ")", "if", "block_given?", "&&", "self", "[", "key", "]", "self", "[", "key", "]", "=", "value", "end", "self", "end" ]
Merge this document with another document, returning the same document in the process. @example Merge with another document. document.merge(name: "Bob") @param [ BSON::Document, Hash ] other The document/hash to merge with. @return [ BSON::Document ] The result of the merge. @since 3.0.0
[ "Merge", "this", "document", "with", "another", "document", "returning", "the", "same", "document", "in", "the", "process", "." ]
297af124a7462f522b75fe9851ac81ce4fd33b0f
https://github.com/mongodb/bson-ruby/blob/297af124a7462f522b75fe9851ac81ce4fd33b0f/lib/bson/document.rb#L200-L206
train
mongodb/bson-ruby
lib/bson/symbol.rb
BSON.Symbol.to_bson_key
def to_bson_key(validating_keys = Config.validating_keys?) if validating_keys raise BSON::String::IllegalKey.new(self) if BSON::String::ILLEGAL_KEY =~ self end self end
ruby
def to_bson_key(validating_keys = Config.validating_keys?) if validating_keys raise BSON::String::IllegalKey.new(self) if BSON::String::ILLEGAL_KEY =~ self end self end
[ "def", "to_bson_key", "(", "validating_keys", "=", "Config", ".", "validating_keys?", ")", "if", "validating_keys", "raise", "BSON", "::", "String", "::", "IllegalKey", ".", "new", "(", "self", ")", "if", "BSON", "::", "String", "::", "ILLEGAL_KEY", "=~", "self", "end", "self", "end" ]
Get the symbol as a BSON key name encoded C symbol. @example Get the symbol as a key name. :test.to_bson_key @return [ String ] The encoded symbol as a BSON key. @see http://bsonspec.org/#/specification @since 2.0.0
[ "Get", "the", "symbol", "as", "a", "BSON", "key", "name", "encoded", "C", "symbol", "." ]
297af124a7462f522b75fe9851ac81ce4fd33b0f
https://github.com/mongodb/bson-ruby/blob/297af124a7462f522b75fe9851ac81ce4fd33b0f/lib/bson/symbol.rb#L73-L78
train
YorickPeterse/ruby-lint
lib/ruby-lint/inspector.rb
RubyLint.Inspector.inspect_methods
def inspect_methods return [] unless constant.respond_to?(:methods) methods = get_methods.map do |name| method_information(:method, name) end return methods.sort_by(&:name) end
ruby
def inspect_methods return [] unless constant.respond_to?(:methods) methods = get_methods.map do |name| method_information(:method, name) end return methods.sort_by(&:name) end
[ "def", "inspect_methods", "return", "[", "]", "unless", "constant", ".", "respond_to?", "(", ":methods", ")", "methods", "=", "get_methods", ".", "map", "do", "|", "name", "|", "method_information", "(", ":method", ",", "name", ")", "end", "return", "methods", ".", "sort_by", "(", "&", ":name", ")", "end" ]
Returns an Array containing all method objects sorted by their names. @return [Array]
[ "Returns", "an", "Array", "containing", "all", "method", "objects", "sorted", "by", "their", "names", "." ]
87842ae295c2283d8e02d951781189486a7cc970
https://github.com/YorickPeterse/ruby-lint/blob/87842ae295c2283d8e02d951781189486a7cc970/lib/ruby-lint/inspector.rb#L94-L102
train
YorickPeterse/ruby-lint
lib/ruby-lint/inspector.rb
RubyLint.Inspector.inspect_modules
def inspect_modules modules = [] if constant.respond_to?(:ancestors) parent = inspect_superclass # Take all the modules included *directly* into the constant. modules = constant.ancestors.take_while do |ancestor| parent && ancestor != parent end # Get rid of non Module instances and modules that don't have a name. modules = modules.select do |mod| mod.instance_of?(Module) && mod.name end end return modules end
ruby
def inspect_modules modules = [] if constant.respond_to?(:ancestors) parent = inspect_superclass # Take all the modules included *directly* into the constant. modules = constant.ancestors.take_while do |ancestor| parent && ancestor != parent end # Get rid of non Module instances and modules that don't have a name. modules = modules.select do |mod| mod.instance_of?(Module) && mod.name end end return modules end
[ "def", "inspect_modules", "modules", "=", "[", "]", "if", "constant", ".", "respond_to?", "(", ":ancestors", ")", "parent", "=", "inspect_superclass", "modules", "=", "constant", ".", "ancestors", ".", "take_while", "do", "|", "ancestor", "|", "parent", "&&", "ancestor", "!=", "parent", "end", "modules", "=", "modules", ".", "select", "do", "|", "mod", "|", "mod", ".", "instance_of?", "(", "Module", ")", "&&", "mod", ".", "name", "end", "end", "return", "modules", "end" ]
Returns the modules that are included in the constant. @return [Array]
[ "Returns", "the", "modules", "that", "are", "included", "in", "the", "constant", "." ]
87842ae295c2283d8e02d951781189486a7cc970
https://github.com/YorickPeterse/ruby-lint/blob/87842ae295c2283d8e02d951781189486a7cc970/lib/ruby-lint/inspector.rb#L124-L142
train
YorickPeterse/ruby-lint
lib/ruby-lint/inspector.rb
RubyLint.Inspector.inspect_superclass
def inspect_superclass parent = nil if constant.respond_to?(:superclass) \ and constant.superclass \ and constant.superclass.name return constant.superclass end return parent end
ruby
def inspect_superclass parent = nil if constant.respond_to?(:superclass) \ and constant.superclass \ and constant.superclass.name return constant.superclass end return parent end
[ "def", "inspect_superclass", "parent", "=", "nil", "if", "constant", ".", "respond_to?", "(", ":superclass", ")", "and", "constant", ".", "superclass", "and", "constant", ".", "superclass", ".", "name", "return", "constant", ".", "superclass", "end", "return", "parent", "end" ]
Returns the superclass of the current constant or `nil` if there is none. @return [Mixed]
[ "Returns", "the", "superclass", "of", "the", "current", "constant", "or", "nil", "if", "there", "is", "none", "." ]
87842ae295c2283d8e02d951781189486a7cc970
https://github.com/YorickPeterse/ruby-lint/blob/87842ae295c2283d8e02d951781189486a7cc970/lib/ruby-lint/inspector.rb#L149-L159
train
YorickPeterse/ruby-lint
lib/ruby-lint/inspector.rb
RubyLint.Inspector.get_methods
def get_methods(getter = :methods) parent = inspect_superclass || Object diff = constant.__send__(getter, false) - parent.__send__(getter, false) methods = diff | constant.__send__(getter, false) # If the constant manually defines the initialize method (= private) # we'll also want to include it. if include_initialize?(getter) methods = methods | [:initialize] end return methods end
ruby
def get_methods(getter = :methods) parent = inspect_superclass || Object diff = constant.__send__(getter, false) - parent.__send__(getter, false) methods = diff | constant.__send__(getter, false) # If the constant manually defines the initialize method (= private) # we'll also want to include it. if include_initialize?(getter) methods = methods | [:initialize] end return methods end
[ "def", "get_methods", "(", "getter", "=", ":methods", ")", "parent", "=", "inspect_superclass", "||", "Object", "diff", "=", "constant", ".", "__send__", "(", "getter", ",", "false", ")", "-", "parent", ".", "__send__", "(", "getter", ",", "false", ")", "methods", "=", "diff", "|", "constant", ".", "__send__", "(", "getter", ",", "false", ")", "if", "include_initialize?", "(", "getter", ")", "methods", "=", "methods", "|", "[", ":initialize", "]", "end", "return", "methods", "end" ]
Gets the methods of the current constant minus those defined in Object. @param [Symbol] getter @return [Array]
[ "Gets", "the", "methods", "of", "the", "current", "constant", "minus", "those", "defined", "in", "Object", "." ]
87842ae295c2283d8e02d951781189486a7cc970
https://github.com/YorickPeterse/ruby-lint/blob/87842ae295c2283d8e02d951781189486a7cc970/lib/ruby-lint/inspector.rb#L167-L181
train
YorickPeterse/ruby-lint
lib/ruby-lint/inspector.rb
RubyLint.Inspector.resolve_constant
def resolve_constant(constant) current = Object final = nil constant.split('::').each do |segment| if current.const_defined?(segment) current = final = current.const_get(segment) else raise( ArgumentError, "Constant #{segment} does not exist in #{constant}" ) end end return final end
ruby
def resolve_constant(constant) current = Object final = nil constant.split('::').each do |segment| if current.const_defined?(segment) current = final = current.const_get(segment) else raise( ArgumentError, "Constant #{segment} does not exist in #{constant}" ) end end return final end
[ "def", "resolve_constant", "(", "constant", ")", "current", "=", "Object", "final", "=", "nil", "constant", ".", "split", "(", "'::'", ")", ".", "each", "do", "|", "segment", "|", "if", "current", ".", "const_defined?", "(", "segment", ")", "current", "=", "final", "=", "current", ".", "const_get", "(", "segment", ")", "else", "raise", "(", "ArgumentError", ",", "\"Constant #{segment} does not exist in #{constant}\"", ")", "end", "end", "return", "final", "end" ]
Converts a String based constant path into an actual constant. @param [String] constant @return [Class] @raise [ArgumentError] Raised when one of the segments doesn't exist.
[ "Converts", "a", "String", "based", "constant", "path", "into", "an", "actual", "constant", "." ]
87842ae295c2283d8e02d951781189486a7cc970
https://github.com/YorickPeterse/ruby-lint/blob/87842ae295c2283d8e02d951781189486a7cc970/lib/ruby-lint/inspector.rb#L243-L259
train
YorickPeterse/ruby-lint
lib/ruby-lint/iterator.rb
RubyLint.Iterator.execute_callback
def execute_callback(name, *args) return unless respond_to?(name) unless arity_cache.key?(name) arity_cache[name] = method(name).arity end if arity_cache[name] == 0 send(name) else send(name, *args) end end
ruby
def execute_callback(name, *args) return unless respond_to?(name) unless arity_cache.key?(name) arity_cache[name] = method(name).arity end if arity_cache[name] == 0 send(name) else send(name, *args) end end
[ "def", "execute_callback", "(", "name", ",", "*", "args", ")", "return", "unless", "respond_to?", "(", "name", ")", "unless", "arity_cache", ".", "key?", "(", "name", ")", "arity_cache", "[", "name", "]", "=", "method", "(", "name", ")", ".", "arity", "end", "if", "arity_cache", "[", "name", "]", "==", "0", "send", "(", "name", ")", "else", "send", "(", "name", ",", "*", "args", ")", "end", "end" ]
Executes the specified callback method if it exists. @param [String|Symbol] name The name of the callback method to execute. @param [Array] args Arguments to pass to the callback method.
[ "Executes", "the", "specified", "callback", "method", "if", "it", "exists", "." ]
87842ae295c2283d8e02d951781189486a7cc970
https://github.com/YorickPeterse/ruby-lint/blob/87842ae295c2283d8e02d951781189486a7cc970/lib/ruby-lint/iterator.rb#L115-L127
train
YorickPeterse/ruby-lint
lib/ruby-lint/constant_path.rb
RubyLint.ConstantPath.constant_segments
def constant_segments(node = self.node) segments = [] if has_child_node?(node) segments.concat(constant_segments(node.children[0])) end segments << [node.type, name_for_node(node)] return segments end
ruby
def constant_segments(node = self.node) segments = [] if has_child_node?(node) segments.concat(constant_segments(node.children[0])) end segments << [node.type, name_for_node(node)] return segments end
[ "def", "constant_segments", "(", "node", "=", "self", ".", "node", ")", "segments", "=", "[", "]", "if", "has_child_node?", "(", "node", ")", "segments", ".", "concat", "(", "constant_segments", "(", "node", ".", "children", "[", "0", "]", ")", ")", "end", "segments", "<<", "[", "node", ".", "type", ",", "name_for_node", "(", "node", ")", "]", "return", "segments", "end" ]
Returns an Array containing the segments of a constant path. @param [RubyLint::AST::Node] node @return [Array<Array(Symbol,String)>]
[ "Returns", "an", "Array", "containing", "the", "segments", "of", "a", "constant", "path", "." ]
87842ae295c2283d8e02d951781189486a7cc970
https://github.com/YorickPeterse/ruby-lint/blob/87842ae295c2283d8e02d951781189486a7cc970/lib/ruby-lint/constant_path.rb#L74-L84
train
YorickPeterse/ruby-lint
lib/ruby-lint/constant_loader.rb
RubyLint.ConstantLoader.bootstrap
def bootstrap types = VariablePredicates::RUBY_CLASSES.values (BOOTSTRAP_CONSTS | types).each do |name| load_constant(name) end BOOTSTRAP_GVARS.each do |gvar| definitions.define_global_variable(gvar) end end
ruby
def bootstrap types = VariablePredicates::RUBY_CLASSES.values (BOOTSTRAP_CONSTS | types).each do |name| load_constant(name) end BOOTSTRAP_GVARS.each do |gvar| definitions.define_global_variable(gvar) end end
[ "def", "bootstrap", "types", "=", "VariablePredicates", "::", "RUBY_CLASSES", ".", "values", "(", "BOOTSTRAP_CONSTS", "|", "types", ")", ".", "each", "do", "|", "name", "|", "load_constant", "(", "name", ")", "end", "BOOTSTRAP_GVARS", ".", "each", "do", "|", "gvar", "|", "definitions", ".", "define_global_variable", "(", "gvar", ")", "end", "end" ]
Bootstraps various core definitions.
[ "Bootstraps", "various", "core", "definitions", "." ]
87842ae295c2283d8e02d951781189486a7cc970
https://github.com/YorickPeterse/ruby-lint/blob/87842ae295c2283d8e02d951781189486a7cc970/lib/ruby-lint/constant_loader.rb#L49-L59
train
YorickPeterse/ruby-lint
lib/ruby-lint/constant_loader.rb
RubyLint.ConstantLoader.load_nested_constant
def load_nested_constant(constant) if constant.start_with?("::") constant = constant.sub(/^::/, "") else # ["A", "B", "C"] -> ["A::B::C", "A::B", "A"] namespaces = module_nesting.size.downto(1).map do |n| module_nesting.take(n).join("::") end namespaces.each do |ns| load_constant("#{ns}::#{constant}") end end load_constant(constant) end
ruby
def load_nested_constant(constant) if constant.start_with?("::") constant = constant.sub(/^::/, "") else # ["A", "B", "C"] -> ["A::B::C", "A::B", "A"] namespaces = module_nesting.size.downto(1).map do |n| module_nesting.take(n).join("::") end namespaces.each do |ns| load_constant("#{ns}::#{constant}") end end load_constant(constant) end
[ "def", "load_nested_constant", "(", "constant", ")", "if", "constant", ".", "start_with?", "(", "\"::\"", ")", "constant", "=", "constant", ".", "sub", "(", "/", "/", ",", "\"\"", ")", "else", "namespaces", "=", "module_nesting", ".", "size", ".", "downto", "(", "1", ")", ".", "map", "do", "|", "n", "|", "module_nesting", ".", "take", "(", "n", ")", ".", "join", "(", "\"::\"", ")", "end", "namespaces", ".", "each", "do", "|", "ns", "|", "load_constant", "(", "\"#{ns}::#{constant}\"", ")", "end", "end", "load_constant", "(", "constant", ")", "end" ]
Tries to load the definitions for the given constant. Takes into account what modules we are in to resolve the constant name. @param [String] constant name, possibly unqualified
[ "Tries", "to", "load", "the", "definitions", "for", "the", "given", "constant", ".", "Takes", "into", "account", "what", "modules", "we", "are", "in", "to", "resolve", "the", "constant", "name", "." ]
87842ae295c2283d8e02d951781189486a7cc970
https://github.com/YorickPeterse/ruby-lint/blob/87842ae295c2283d8e02d951781189486a7cc970/lib/ruby-lint/constant_loader.rb#L131-L145
train
YorickPeterse/ruby-lint
lib/ruby-lint/constant_loader.rb
RubyLint.ConstantLoader.load_constant
def load_constant(constant) return if loaded?(constant) registry.load(constant) return unless registry.include?(constant) apply(constant) end
ruby
def load_constant(constant) return if loaded?(constant) registry.load(constant) return unless registry.include?(constant) apply(constant) end
[ "def", "load_constant", "(", "constant", ")", "return", "if", "loaded?", "(", "constant", ")", "registry", ".", "load", "(", "constant", ")", "return", "unless", "registry", ".", "include?", "(", "constant", ")", "apply", "(", "constant", ")", "end" ]
Tries to load the definitions for the given constant. @param [String] constant
[ "Tries", "to", "load", "the", "definitions", "for", "the", "given", "constant", "." ]
87842ae295c2283d8e02d951781189486a7cc970
https://github.com/YorickPeterse/ruby-lint/blob/87842ae295c2283d8e02d951781189486a7cc970/lib/ruby-lint/constant_loader.rb#L152-L160
train
YorickPeterse/ruby-lint
lib/ruby-lint/configuration.rb
RubyLint.Configuration.report_levels=
def report_levels=(given) available = self.class.available_report_levels levels = [] given.each do |level| levels << available[level] if available[level] end if levels.empty? levels = default_report_levels end @report_levels = levels end
ruby
def report_levels=(given) available = self.class.available_report_levels levels = [] given.each do |level| levels << available[level] if available[level] end if levels.empty? levels = default_report_levels end @report_levels = levels end
[ "def", "report_levels", "=", "(", "given", ")", "available", "=", "self", ".", "class", ".", "available_report_levels", "levels", "=", "[", "]", "given", ".", "each", "do", "|", "level", "|", "levels", "<<", "available", "[", "level", "]", "if", "available", "[", "level", "]", "end", "if", "levels", ".", "empty?", "levels", "=", "default_report_levels", "end", "@report_levels", "=", "levels", "end" ]
Sets a list of the enabled report levels. @param [Array] given The report levels specified by the user. @return [Array]
[ "Sets", "a", "list", "of", "the", "enabled", "report", "levels", "." ]
87842ae295c2283d8e02d951781189486a7cc970
https://github.com/YorickPeterse/ruby-lint/blob/87842ae295c2283d8e02d951781189486a7cc970/lib/ruby-lint/configuration.rb#L135-L148
train
YorickPeterse/ruby-lint
lib/ruby-lint/configuration.rb
RubyLint.Configuration.analysis_classes=
def analysis_classes=(names) classes = [] available = self.class.available_analysis_classes names.each do |name| classes << available[name] if available[name] end if classes.empty? classes = default_analysis_classes end @analysis_classes = classes end
ruby
def analysis_classes=(names) classes = [] available = self.class.available_analysis_classes names.each do |name| classes << available[name] if available[name] end if classes.empty? classes = default_analysis_classes end @analysis_classes = classes end
[ "def", "analysis_classes", "=", "(", "names", ")", "classes", "=", "[", "]", "available", "=", "self", ".", "class", ".", "available_analysis_classes", "names", ".", "each", "do", "|", "name", "|", "classes", "<<", "available", "[", "name", "]", "if", "available", "[", "name", "]", "end", "if", "classes", ".", "empty?", "classes", "=", "default_analysis_classes", "end", "@analysis_classes", "=", "classes", "end" ]
Sets a collection of the analysis constants to use. @param [Array] names The analysis names as given by the user. @return [Array]
[ "Sets", "a", "collection", "of", "the", "analysis", "constants", "to", "use", "." ]
87842ae295c2283d8e02d951781189486a7cc970
https://github.com/YorickPeterse/ruby-lint/blob/87842ae295c2283d8e02d951781189486a7cc970/lib/ruby-lint/configuration.rb#L174-L187
train
YorickPeterse/ruby-lint
lib/ruby-lint/rake_task.rb
RubyLint.RakeTask.run_task
def run_task config = create_configuration runner = RubyLint::Runner.new(config) list = FileList.new output = runner.analyze(list.process(files)) puts(output) unless output.empty? end
ruby
def run_task config = create_configuration runner = RubyLint::Runner.new(config) list = FileList.new output = runner.analyze(list.process(files)) puts(output) unless output.empty? end
[ "def", "run_task", "config", "=", "create_configuration", "runner", "=", "RubyLint", "::", "Runner", ".", "new", "(", "config", ")", "list", "=", "FileList", ".", "new", "output", "=", "runner", ".", "analyze", "(", "list", ".", "process", "(", "files", ")", ")", "puts", "(", "output", ")", "unless", "output", ".", "empty?", "end" ]
Processes a list of files and writes the output to STDOUT.
[ "Processes", "a", "list", "of", "files", "and", "writes", "the", "output", "to", "STDOUT", "." ]
87842ae295c2283d8e02d951781189486a7cc970
https://github.com/YorickPeterse/ruby-lint/blob/87842ae295c2283d8e02d951781189486a7cc970/lib/ruby-lint/rake_task.rb#L73-L80
train
YorickPeterse/ruby-lint
lib/ruby-lint/file_scanner.rb
RubyLint.FileScanner.build_constant_paths_cache
def build_constant_paths_cache(constant) paths = match_globbed_files(constant_to_path(constant)) # Lets see if we can find anything when using dashes for the directory # names instead of underscores. if paths.empty? paths = match_globbed_files(constant_to_dashed_path(constant)) end paths.map! { |p| File.expand_path(p) } ignore.each do |pattern| paths.reject! do |path| path.include?(pattern) end end # Ensure that the order is from top-level -> deeply nested files # instead of a random order. paths.sort! do |left, right| left.length <=> right.length end @constant_paths_cache[constant] = paths end
ruby
def build_constant_paths_cache(constant) paths = match_globbed_files(constant_to_path(constant)) # Lets see if we can find anything when using dashes for the directory # names instead of underscores. if paths.empty? paths = match_globbed_files(constant_to_dashed_path(constant)) end paths.map! { |p| File.expand_path(p) } ignore.each do |pattern| paths.reject! do |path| path.include?(pattern) end end # Ensure that the order is from top-level -> deeply nested files # instead of a random order. paths.sort! do |left, right| left.length <=> right.length end @constant_paths_cache[constant] = paths end
[ "def", "build_constant_paths_cache", "(", "constant", ")", "paths", "=", "match_globbed_files", "(", "constant_to_path", "(", "constant", ")", ")", "if", "paths", ".", "empty?", "paths", "=", "match_globbed_files", "(", "constant_to_dashed_path", "(", "constant", ")", ")", "end", "paths", ".", "map!", "{", "|", "p", "|", "File", ".", "expand_path", "(", "p", ")", "}", "ignore", ".", "each", "do", "|", "pattern", "|", "paths", ".", "reject!", "do", "|", "path", "|", "path", ".", "include?", "(", "pattern", ")", "end", "end", "paths", ".", "sort!", "do", "|", "left", ",", "right", "|", "left", ".", "length", "<=>", "right", ".", "length", "end", "@constant_paths_cache", "[", "constant", "]", "=", "paths", "end" ]
Searches all the files that could potentially define the given constant and caches them. @param [String] constant
[ "Searches", "all", "the", "files", "that", "could", "potentially", "define", "the", "given", "constant", "and", "caches", "them", "." ]
87842ae295c2283d8e02d951781189486a7cc970
https://github.com/YorickPeterse/ruby-lint/blob/87842ae295c2283d8e02d951781189486a7cc970/lib/ruby-lint/file_scanner.rb#L130-L154
train
YorickPeterse/ruby-lint
lib/ruby-lint/runner.rb
RubyLint.Runner.parse_file
def parse_file(parser, file) return parser.parse(File.read(file, :encoding => Encoding::UTF_8), file) end
ruby
def parse_file(parser, file) return parser.parse(File.read(file, :encoding => Encoding::UTF_8), file) end
[ "def", "parse_file", "(", "parser", ",", "file", ")", "return", "parser", ".", "parse", "(", "File", ".", "read", "(", "file", ",", ":encoding", "=>", "Encoding", "::", "UTF_8", ")", ",", "file", ")", "end" ]
Parses the given file and returns an Array containing all the associated AST nodes and comments. @param [RubyLint::Parser] parser @param [String] file @return [Array]
[ "Parses", "the", "given", "file", "and", "returns", "an", "Array", "containing", "all", "the", "associated", "AST", "nodes", "and", "comments", "." ]
87842ae295c2283d8e02d951781189486a7cc970
https://github.com/YorickPeterse/ruby-lint/blob/87842ae295c2283d8e02d951781189486a7cc970/lib/ruby-lint/runner.rb#L71-L73
train
YorickPeterse/ruby-lint
lib/ruby-lint/runner.rb
RubyLint.Runner.run_analysis
def run_analysis(ast, vm, report) classes = configuration.analysis_classes.select do |const| const.analyze?(ast, vm) end classes.each do |const| instance = const.new( :vm => vm, :report => report, :config => configuration ) instance.iterate(ast) end end
ruby
def run_analysis(ast, vm, report) classes = configuration.analysis_classes.select do |const| const.analyze?(ast, vm) end classes.each do |const| instance = const.new( :vm => vm, :report => report, :config => configuration ) instance.iterate(ast) end end
[ "def", "run_analysis", "(", "ast", ",", "vm", ",", "report", ")", "classes", "=", "configuration", ".", "analysis_classes", ".", "select", "do", "|", "const", "|", "const", ".", "analyze?", "(", "ast", ",", "vm", ")", "end", "classes", ".", "each", "do", "|", "const", "|", "instance", "=", "const", ".", "new", "(", ":vm", "=>", "vm", ",", ":report", "=>", "report", ",", ":config", "=>", "configuration", ")", "instance", ".", "iterate", "(", "ast", ")", "end", "end" ]
Runs all the registered analysis classes. @param [RubyLint::AST::Node] ast @param [RubyLint::VirtualMachine] vm @param [RubyLint::Report] report
[ "Runs", "all", "the", "registered", "analysis", "classes", "." ]
87842ae295c2283d8e02d951781189486a7cc970
https://github.com/YorickPeterse/ruby-lint/blob/87842ae295c2283d8e02d951781189486a7cc970/lib/ruby-lint/runner.rb#L137-L151
train
YorickPeterse/ruby-lint
lib/ruby-lint/virtual_machine.rb
RubyLint.VirtualMachine.after_initialize
def after_initialize @comments ||= {} @associations = {} @definitions = initial_definitions @constant_loader = ConstantLoader.new(:definitions => @definitions) @scopes = [@definitions] @value_stack = NestedStack.new @variable_stack = NestedStack.new @ignored_nodes = [] @visibility = :public reset_docstring_tags reset_method_type @constant_loader.bootstrap end
ruby
def after_initialize @comments ||= {} @associations = {} @definitions = initial_definitions @constant_loader = ConstantLoader.new(:definitions => @definitions) @scopes = [@definitions] @value_stack = NestedStack.new @variable_stack = NestedStack.new @ignored_nodes = [] @visibility = :public reset_docstring_tags reset_method_type @constant_loader.bootstrap end
[ "def", "after_initialize", "@comments", "||=", "{", "}", "@associations", "=", "{", "}", "@definitions", "=", "initial_definitions", "@constant_loader", "=", "ConstantLoader", ".", "new", "(", ":definitions", "=>", "@definitions", ")", "@scopes", "=", "[", "@definitions", "]", "@value_stack", "=", "NestedStack", ".", "new", "@variable_stack", "=", "NestedStack", ".", "new", "@ignored_nodes", "=", "[", "]", "@visibility", "=", ":public", "reset_docstring_tags", "reset_method_type", "@constant_loader", ".", "bootstrap", "end" ]
Called after a new instance of the virtual machine has been created.
[ "Called", "after", "a", "new", "instance", "of", "the", "virtual", "machine", "has", "been", "created", "." ]
87842ae295c2283d8e02d951781189486a7cc970
https://github.com/YorickPeterse/ruby-lint/blob/87842ae295c2283d8e02d951781189486a7cc970/lib/ruby-lint/virtual_machine.rb#L165-L181
train
YorickPeterse/ruby-lint
lib/ruby-lint/virtual_machine.rb
RubyLint.VirtualMachine.run
def run(ast) ast = [ast] unless ast.is_a?(Array) # pre-load all the built-in definitions. @constant_loader.run(ast) ast.each { |node| iterate(node) } freeze end
ruby
def run(ast) ast = [ast] unless ast.is_a?(Array) # pre-load all the built-in definitions. @constant_loader.run(ast) ast.each { |node| iterate(node) } freeze end
[ "def", "run", "(", "ast", ")", "ast", "=", "[", "ast", "]", "unless", "ast", ".", "is_a?", "(", "Array", ")", "@constant_loader", ".", "run", "(", "ast", ")", "ast", ".", "each", "{", "|", "node", "|", "iterate", "(", "node", ")", "}", "freeze", "end" ]
Processes the given AST or a collection of AST nodes. @see #iterate @param [Array|RubyLint::AST::Node] ast
[ "Processes", "the", "given", "AST", "or", "a", "collection", "of", "AST", "nodes", "." ]
87842ae295c2283d8e02d951781189486a7cc970
https://github.com/YorickPeterse/ruby-lint/blob/87842ae295c2283d8e02d951781189486a7cc970/lib/ruby-lint/virtual_machine.rb#L189-L198
train
YorickPeterse/ruby-lint
lib/ruby-lint/virtual_machine.rb
RubyLint.VirtualMachine.after_or_asgn
def after_or_asgn variable = variable_stack.pop.first value = value_stack.pop.first if variable and value conditional_assignment(variable, value, false) end end
ruby
def after_or_asgn variable = variable_stack.pop.first value = value_stack.pop.first if variable and value conditional_assignment(variable, value, false) end end
[ "def", "after_or_asgn", "variable", "=", "variable_stack", ".", "pop", ".", "first", "value", "=", "value_stack", ".", "pop", ".", "first", "if", "variable", "and", "value", "conditional_assignment", "(", "variable", ",", "value", ",", "false", ")", "end", "end" ]
Processes an `or` assignment in the form of `variable ||= value`.
[ "Processes", "an", "or", "assignment", "in", "the", "form", "of", "variable", "||", "=", "value", "." ]
87842ae295c2283d8e02d951781189486a7cc970
https://github.com/YorickPeterse/ruby-lint/blob/87842ae295c2283d8e02d951781189486a7cc970/lib/ruby-lint/virtual_machine.rb#L311-L318
train
YorickPeterse/ruby-lint
lib/ruby-lint/virtual_machine.rb
RubyLint.VirtualMachine.after_and_asgn
def after_and_asgn variable = variable_stack.pop.first value = value_stack.pop.first conditional_assignment(variable, value) end
ruby
def after_and_asgn variable = variable_stack.pop.first value = value_stack.pop.first conditional_assignment(variable, value) end
[ "def", "after_and_asgn", "variable", "=", "variable_stack", ".", "pop", ".", "first", "value", "=", "value_stack", ".", "pop", ".", "first", "conditional_assignment", "(", "variable", ",", "value", ")", "end" ]
Processes an `and` assignment in the form of `variable &&= value`.
[ "Processes", "an", "and", "assignment", "in", "the", "form", "of", "variable", "&&", "=", "value", "." ]
87842ae295c2283d8e02d951781189486a7cc970
https://github.com/YorickPeterse/ruby-lint/blob/87842ae295c2283d8e02d951781189486a7cc970/lib/ruby-lint/virtual_machine.rb#L327-L332
train
YorickPeterse/ruby-lint
lib/ruby-lint/virtual_machine.rb
RubyLint.VirtualMachine.after_array
def after_array(node) builder = DefinitionBuilder::RubyArray.new( node, self, :values => value_stack.pop ) push_value(builder.build) end
ruby
def after_array(node) builder = DefinitionBuilder::RubyArray.new( node, self, :values => value_stack.pop ) push_value(builder.build) end
[ "def", "after_array", "(", "node", ")", "builder", "=", "DefinitionBuilder", "::", "RubyArray", ".", "new", "(", "node", ",", "self", ",", ":values", "=>", "value_stack", ".", "pop", ")", "push_value", "(", "builder", ".", "build", ")", "end" ]
Builds an Array. @param [RubyLint::AST::Node] node
[ "Builds", "an", "Array", "." ]
87842ae295c2283d8e02d951781189486a7cc970
https://github.com/YorickPeterse/ruby-lint/blob/87842ae295c2283d8e02d951781189486a7cc970/lib/ruby-lint/virtual_machine.rb#L387-L395
train
YorickPeterse/ruby-lint
lib/ruby-lint/virtual_machine.rb
RubyLint.VirtualMachine.after_hash
def after_hash(node) builder = DefinitionBuilder::RubyHash.new( node, self, :values => value_stack.pop ) push_value(builder.build) end
ruby
def after_hash(node) builder = DefinitionBuilder::RubyHash.new( node, self, :values => value_stack.pop ) push_value(builder.build) end
[ "def", "after_hash", "(", "node", ")", "builder", "=", "DefinitionBuilder", "::", "RubyHash", ".", "new", "(", "node", ",", "self", ",", ":values", "=>", "value_stack", ".", "pop", ")", "push_value", "(", "builder", ".", "build", ")", "end" ]
Builds a Hash. @param [RubyLint::AST::Node] node
[ "Builds", "a", "Hash", "." ]
87842ae295c2283d8e02d951781189486a7cc970
https://github.com/YorickPeterse/ruby-lint/blob/87842ae295c2283d8e02d951781189486a7cc970/lib/ruby-lint/virtual_machine.rb#L409-L417
train
YorickPeterse/ruby-lint
lib/ruby-lint/virtual_machine.rb
RubyLint.VirtualMachine.on_self
def on_self scope = current_scope method = scope.lookup(scope.method_call_type, 'self') push_value(method.return_value) end
ruby
def on_self scope = current_scope method = scope.lookup(scope.method_call_type, 'self') push_value(method.return_value) end
[ "def", "on_self", "scope", "=", "current_scope", "method", "=", "scope", ".", "lookup", "(", "scope", ".", "method_call_type", ",", "'self'", ")", "push_value", "(", "method", ".", "return_value", ")", "end" ]
Pushes the value of `self` onto the current stack.
[ "Pushes", "the", "value", "of", "self", "onto", "the", "current", "stack", "." ]
87842ae295c2283d8e02d951781189486a7cc970
https://github.com/YorickPeterse/ruby-lint/blob/87842ae295c2283d8e02d951781189486a7cc970/lib/ruby-lint/virtual_machine.rb#L446-L451
train
YorickPeterse/ruby-lint
lib/ruby-lint/virtual_machine.rb
RubyLint.VirtualMachine.on_class
def on_class(node) parent = nil parent_node = node.children[1] if parent_node parent = evaluate_node(parent_node) if !parent or !parent.const? # FIXME: this should use `definitions` instead. parent = current_scope.lookup(:const, 'Object') end end define_module(node, DefinitionBuilder::RubyClass, :parent => parent) end
ruby
def on_class(node) parent = nil parent_node = node.children[1] if parent_node parent = evaluate_node(parent_node) if !parent or !parent.const? # FIXME: this should use `definitions` instead. parent = current_scope.lookup(:const, 'Object') end end define_module(node, DefinitionBuilder::RubyClass, :parent => parent) end
[ "def", "on_class", "(", "node", ")", "parent", "=", "nil", "parent_node", "=", "node", ".", "children", "[", "1", "]", "if", "parent_node", "parent", "=", "evaluate_node", "(", "parent_node", ")", "if", "!", "parent", "or", "!", "parent", ".", "const?", "parent", "=", "current_scope", ".", "lookup", "(", ":const", ",", "'Object'", ")", "end", "end", "define_module", "(", "node", ",", "DefinitionBuilder", "::", "RubyClass", ",", ":parent", "=>", "parent", ")", "end" ]
Creates the definition for a class. @param [RubyLint::AST::Node] node
[ "Creates", "the", "definition", "for", "a", "class", "." ]
87842ae295c2283d8e02d951781189486a7cc970
https://github.com/YorickPeterse/ruby-lint/blob/87842ae295c2283d8e02d951781189486a7cc970/lib/ruby-lint/virtual_machine.rb#L481-L495
train
YorickPeterse/ruby-lint
lib/ruby-lint/virtual_machine.rb
RubyLint.VirtualMachine.on_block
def on_block(node) builder = DefinitionBuilder::RubyBlock.new(node, self) definition = builder.build associate_node(node, definition) push_scope(definition) end
ruby
def on_block(node) builder = DefinitionBuilder::RubyBlock.new(node, self) definition = builder.build associate_node(node, definition) push_scope(definition) end
[ "def", "on_block", "(", "node", ")", "builder", "=", "DefinitionBuilder", "::", "RubyBlock", ".", "new", "(", "node", ",", "self", ")", "definition", "=", "builder", ".", "build", "associate_node", "(", "node", ",", "definition", ")", "push_scope", "(", "definition", ")", "end" ]
Builds the definition for a block. @param [RubyLint::AST::Node] node
[ "Builds", "the", "definition", "for", "a", "block", "." ]
87842ae295c2283d8e02d951781189486a7cc970
https://github.com/YorickPeterse/ruby-lint/blob/87842ae295c2283d8e02d951781189486a7cc970/lib/ruby-lint/virtual_machine.rb#L509-L516
train
YorickPeterse/ruby-lint
lib/ruby-lint/virtual_machine.rb
RubyLint.VirtualMachine.on_def
def on_def(node) receiver = nil if node.type == :defs receiver = evaluate_node(node.children[0]) end builder = DefinitionBuilder::RubyMethod.new( node, self, :type => @method_type, :receiver => receiver, :visibility => @visibility ) definition = builder.build builder.scope.add_definition(definition) associate_node(node, definition) buffer_docstring_tags(node) if docstring_tags and docstring_tags.return_tag assign_return_value_from_tag( docstring_tags.return_tag, definition ) end push_scope(definition) end
ruby
def on_def(node) receiver = nil if node.type == :defs receiver = evaluate_node(node.children[0]) end builder = DefinitionBuilder::RubyMethod.new( node, self, :type => @method_type, :receiver => receiver, :visibility => @visibility ) definition = builder.build builder.scope.add_definition(definition) associate_node(node, definition) buffer_docstring_tags(node) if docstring_tags and docstring_tags.return_tag assign_return_value_from_tag( docstring_tags.return_tag, definition ) end push_scope(definition) end
[ "def", "on_def", "(", "node", ")", "receiver", "=", "nil", "if", "node", ".", "type", "==", ":defs", "receiver", "=", "evaluate_node", "(", "node", ".", "children", "[", "0", "]", ")", "end", "builder", "=", "DefinitionBuilder", "::", "RubyMethod", ".", "new", "(", "node", ",", "self", ",", ":type", "=>", "@method_type", ",", ":receiver", "=>", "receiver", ",", ":visibility", "=>", "@visibility", ")", "definition", "=", "builder", ".", "build", "builder", ".", "scope", ".", "add_definition", "(", "definition", ")", "associate_node", "(", "node", ",", "definition", ")", "buffer_docstring_tags", "(", "node", ")", "if", "docstring_tags", "and", "docstring_tags", ".", "return_tag", "assign_return_value_from_tag", "(", "docstring_tags", ".", "return_tag", ",", "definition", ")", "end", "push_scope", "(", "definition", ")", "end" ]
Creates the definition for a method definition. @param [RubyLint::AST::Node] node
[ "Creates", "the", "definition", "for", "a", "method", "definition", "." ]
87842ae295c2283d8e02d951781189486a7cc970
https://github.com/YorickPeterse/ruby-lint/blob/87842ae295c2283d8e02d951781189486a7cc970/lib/ruby-lint/virtual_machine.rb#L558-L589
train
YorickPeterse/ruby-lint
lib/ruby-lint/virtual_machine.rb
RubyLint.VirtualMachine.after_def
def after_def previous = pop_scope current = current_scope reset_docstring_tags EXPORT_VARIABLES.each do |type| current.copy(previous, type) end end
ruby
def after_def previous = pop_scope current = current_scope reset_docstring_tags EXPORT_VARIABLES.each do |type| current.copy(previous, type) end end
[ "def", "after_def", "previous", "=", "pop_scope", "current", "=", "current_scope", "reset_docstring_tags", "EXPORT_VARIABLES", ".", "each", "do", "|", "type", "|", "current", ".", "copy", "(", "previous", ",", "type", ")", "end", "end" ]
Exports various variables to the outer scope of the method definition.
[ "Exports", "various", "variables", "to", "the", "outer", "scope", "of", "the", "method", "definition", "." ]
87842ae295c2283d8e02d951781189486a7cc970
https://github.com/YorickPeterse/ruby-lint/blob/87842ae295c2283d8e02d951781189486a7cc970/lib/ruby-lint/virtual_machine.rb#L594-L603
train
YorickPeterse/ruby-lint
lib/ruby-lint/virtual_machine.rb
RubyLint.VirtualMachine.on_send
def on_send(node) name = node.children[1].to_s name = SEND_MAPPING.fetch(name, name) callback = "on_send_#{name}" value_stack.add_stack execute_callback(callback, node) end
ruby
def on_send(node) name = node.children[1].to_s name = SEND_MAPPING.fetch(name, name) callback = "on_send_#{name}" value_stack.add_stack execute_callback(callback, node) end
[ "def", "on_send", "(", "node", ")", "name", "=", "node", ".", "children", "[", "1", "]", ".", "to_s", "name", "=", "SEND_MAPPING", ".", "fetch", "(", "name", ",", "name", ")", "callback", "=", "\"on_send_#{name}\"", "value_stack", ".", "add_stack", "execute_callback", "(", "callback", ",", "node", ")", "end" ]
Processes a method call. If a certain method call has its own dedicated callback that one will be called as well. @param [RubyLint::AST::Node] node
[ "Processes", "a", "method", "call", ".", "If", "a", "certain", "method", "call", "has", "its", "own", "dedicated", "callback", "that", "one", "will", "be", "called", "as", "well", "." ]
87842ae295c2283d8e02d951781189486a7cc970
https://github.com/YorickPeterse/ruby-lint/blob/87842ae295c2283d8e02d951781189486a7cc970/lib/ruby-lint/virtual_machine.rb#L640-L648
train
YorickPeterse/ruby-lint
lib/ruby-lint/virtual_machine.rb
RubyLint.VirtualMachine.initial_definitions
def initial_definitions definitions = Definition::RubyObject.new( :name => 'root', :type => :root, :instance_type => :instance, :inherit_self => false ) definitions.parents = [ definitions.constant_proxy('Object', RubyLint.registry) ] definitions.define_self return definitions end
ruby
def initial_definitions definitions = Definition::RubyObject.new( :name => 'root', :type => :root, :instance_type => :instance, :inherit_self => false ) definitions.parents = [ definitions.constant_proxy('Object', RubyLint.registry) ] definitions.define_self return definitions end
[ "def", "initial_definitions", "definitions", "=", "Definition", "::", "RubyObject", ".", "new", "(", ":name", "=>", "'root'", ",", ":type", "=>", ":root", ",", ":instance_type", "=>", ":instance", ",", ":inherit_self", "=>", "false", ")", "definitions", ".", "parents", "=", "[", "definitions", ".", "constant_proxy", "(", "'Object'", ",", "RubyLint", ".", "registry", ")", "]", "definitions", ".", "define_self", "return", "definitions", "end" ]
Returns the initial set of definitions to use. @return [RubyLint::Definition::RubyObject]
[ "Returns", "the", "initial", "set", "of", "definitions", "to", "use", "." ]
87842ae295c2283d8e02d951781189486a7cc970
https://github.com/YorickPeterse/ruby-lint/blob/87842ae295c2283d8e02d951781189486a7cc970/lib/ruby-lint/virtual_machine.rb#L810-L825
train
YorickPeterse/ruby-lint
lib/ruby-lint/virtual_machine.rb
RubyLint.VirtualMachine.push_scope
def push_scope(definition) unless definition.is_a?(RubyLint::Definition::RubyObject) raise( ArgumentError, "Expected a RubyLint::Definition::RubyObject but got " \ "#{definition.class} instead" ) end @scopes << definition end
ruby
def push_scope(definition) unless definition.is_a?(RubyLint::Definition::RubyObject) raise( ArgumentError, "Expected a RubyLint::Definition::RubyObject but got " \ "#{definition.class} instead" ) end @scopes << definition end
[ "def", "push_scope", "(", "definition", ")", "unless", "definition", ".", "is_a?", "(", "RubyLint", "::", "Definition", "::", "RubyObject", ")", "raise", "(", "ArgumentError", ",", "\"Expected a RubyLint::Definition::RubyObject but got \"", "\"#{definition.class} instead\"", ")", "end", "@scopes", "<<", "definition", "end" ]
Pushes a new scope on the list of available scopes. @param [RubyLint::Definition::RubyObject] definition
[ "Pushes", "a", "new", "scope", "on", "the", "list", "of", "available", "scopes", "." ]
87842ae295c2283d8e02d951781189486a7cc970
https://github.com/YorickPeterse/ruby-lint/blob/87842ae295c2283d8e02d951781189486a7cc970/lib/ruby-lint/virtual_machine.rb#L870-L880
train
YorickPeterse/ruby-lint
lib/ruby-lint/virtual_machine.rb
RubyLint.VirtualMachine.push_variable_value
def push_variable_value(node) return if value_stack.empty? || @ignored_nodes.include?(node) definition = definition_for_node(node) if definition value = definition.value ? definition.value : definition push_value(value) end end
ruby
def push_variable_value(node) return if value_stack.empty? || @ignored_nodes.include?(node) definition = definition_for_node(node) if definition value = definition.value ? definition.value : definition push_value(value) end end
[ "def", "push_variable_value", "(", "node", ")", "return", "if", "value_stack", ".", "empty?", "||", "@ignored_nodes", ".", "include?", "(", "node", ")", "definition", "=", "definition_for_node", "(", "node", ")", "if", "definition", "value", "=", "definition", ".", "value", "?", "definition", ".", "value", ":", "definition", "push_value", "(", "value", ")", "end", "end" ]
Pushes the value of a variable onto the value stack. @param [RubyLint::AST::Node] node
[ "Pushes", "the", "value", "of", "a", "variable", "onto", "the", "value", "stack", "." ]
87842ae295c2283d8e02d951781189486a7cc970
https://github.com/YorickPeterse/ruby-lint/blob/87842ae295c2283d8e02d951781189486a7cc970/lib/ruby-lint/virtual_machine.rb#L896-L906
train
YorickPeterse/ruby-lint
lib/ruby-lint/virtual_machine.rb
RubyLint.VirtualMachine.assign_variable
def assign_variable(type, name, value, node) scope = assignment_scope(type) variable = scope.lookup(type, name) # If there's already a variable we'll just update it. if variable variable.reference_amount += 1 # `value` is not for conditional assignments as those are handled # manually. variable.value = value if value else variable = Definition::RubyObject.new( :type => type, :name => name, :value => value, :instance_type => :instance, :reference_amount => 0, :line => node.line, :column => node.column, :file => node.file ) end buffer_assignment_value(value) # Primarily used by #after_send to support variable assignments as method # call arguments. if value and !value_stack.empty? value_stack.push(variable.value) end add_variable(variable, scope) end
ruby
def assign_variable(type, name, value, node) scope = assignment_scope(type) variable = scope.lookup(type, name) # If there's already a variable we'll just update it. if variable variable.reference_amount += 1 # `value` is not for conditional assignments as those are handled # manually. variable.value = value if value else variable = Definition::RubyObject.new( :type => type, :name => name, :value => value, :instance_type => :instance, :reference_amount => 0, :line => node.line, :column => node.column, :file => node.file ) end buffer_assignment_value(value) # Primarily used by #after_send to support variable assignments as method # call arguments. if value and !value_stack.empty? value_stack.push(variable.value) end add_variable(variable, scope) end
[ "def", "assign_variable", "(", "type", ",", "name", ",", "value", ",", "node", ")", "scope", "=", "assignment_scope", "(", "type", ")", "variable", "=", "scope", ".", "lookup", "(", "type", ",", "name", ")", "if", "variable", "variable", ".", "reference_amount", "+=", "1", "variable", ".", "value", "=", "value", "if", "value", "else", "variable", "=", "Definition", "::", "RubyObject", ".", "new", "(", ":type", "=>", "type", ",", ":name", "=>", "name", ",", ":value", "=>", "value", ",", ":instance_type", "=>", ":instance", ",", ":reference_amount", "=>", "0", ",", ":line", "=>", "node", ".", "line", ",", ":column", "=>", "node", ".", "column", ",", ":file", "=>", "node", ".", "file", ")", "end", "buffer_assignment_value", "(", "value", ")", "if", "value", "and", "!", "value_stack", ".", "empty?", "value_stack", ".", "push", "(", "variable", ".", "value", ")", "end", "add_variable", "(", "variable", ",", "scope", ")", "end" ]
Assigns a basic variable. @param [Symbol] type The type of variable. @param [String] name The name of the variable @param [RubyLint::Definition::RubyObject] value @param [RubyLint::AST::Node] node
[ "Assigns", "a", "basic", "variable", "." ]
87842ae295c2283d8e02d951781189486a7cc970
https://github.com/YorickPeterse/ruby-lint/blob/87842ae295c2283d8e02d951781189486a7cc970/lib/ruby-lint/virtual_machine.rb#L940-L973
train
YorickPeterse/ruby-lint
lib/ruby-lint/virtual_machine.rb
RubyLint.VirtualMachine.add_variable
def add_variable(variable, scope = current_scope) if variable_stack.empty? scope.add(variable.type, variable.name, variable) else variable_stack.push(variable) end end
ruby
def add_variable(variable, scope = current_scope) if variable_stack.empty? scope.add(variable.type, variable.name, variable) else variable_stack.push(variable) end end
[ "def", "add_variable", "(", "variable", ",", "scope", "=", "current_scope", ")", "if", "variable_stack", ".", "empty?", "scope", ".", "add", "(", "variable", ".", "type", ",", "variable", ".", "name", ",", "variable", ")", "else", "variable_stack", ".", "push", "(", "variable", ")", "end", "end" ]
Adds a variable to the current scope of, if a the variable stack is not empty, add it to the stack instead. @param [RubyLint::Definition::RubyObject] variable @param [RubyLint::Definition::RubyObject] scope
[ "Adds", "a", "variable", "to", "the", "current", "scope", "of", "if", "a", "the", "variable", "stack", "is", "not", "empty", "add", "it", "to", "the", "stack", "instead", "." ]
87842ae295c2283d8e02d951781189486a7cc970
https://github.com/YorickPeterse/ruby-lint/blob/87842ae295c2283d8e02d951781189486a7cc970/lib/ruby-lint/virtual_machine.rb#L992-L998
train
YorickPeterse/ruby-lint
lib/ruby-lint/virtual_machine.rb
RubyLint.VirtualMachine.create_primitive
def create_primitive(node, options = {}) builder = DefinitionBuilder::Primitive.new(node, self, options) return builder.build end
ruby
def create_primitive(node, options = {}) builder = DefinitionBuilder::Primitive.new(node, self, options) return builder.build end
[ "def", "create_primitive", "(", "node", ",", "options", "=", "{", "}", ")", "builder", "=", "DefinitionBuilder", "::", "Primitive", ".", "new", "(", "node", ",", "self", ",", "options", ")", "return", "builder", ".", "build", "end" ]
Creates a primitive value such as an integer. @param [RubyLint::AST::Node] node @param [Hash] options
[ "Creates", "a", "primitive", "value", "such", "as", "an", "integer", "." ]
87842ae295c2283d8e02d951781189486a7cc970
https://github.com/YorickPeterse/ruby-lint/blob/87842ae295c2283d8e02d951781189486a7cc970/lib/ruby-lint/virtual_machine.rb#L1006-L1010
train
YorickPeterse/ruby-lint
lib/ruby-lint/virtual_machine.rb
RubyLint.VirtualMachine.conditional_assignment
def conditional_assignment(variable, value, bool = true) variable.reference_amount += 1 if current_scope.has_definition?(variable.type, variable.name) == bool variable.value = value current_scope.add_definition(variable) buffer_assignment_value(variable.value) end end
ruby
def conditional_assignment(variable, value, bool = true) variable.reference_amount += 1 if current_scope.has_definition?(variable.type, variable.name) == bool variable.value = value current_scope.add_definition(variable) buffer_assignment_value(variable.value) end end
[ "def", "conditional_assignment", "(", "variable", ",", "value", ",", "bool", "=", "true", ")", "variable", ".", "reference_amount", "+=", "1", "if", "current_scope", ".", "has_definition?", "(", "variable", ".", "type", ",", "variable", ".", "name", ")", "==", "bool", "variable", ".", "value", "=", "value", "current_scope", ".", "add_definition", "(", "variable", ")", "buffer_assignment_value", "(", "variable", ".", "value", ")", "end", "end" ]
Performs a conditional assignment. @param [RubyLint::Definition::RubyObject] variable @param [RubyLint::Definition::RubyValue] value @param [TrueClass|FalseClass] bool When set to `true` existing variables will be overwritten.
[ "Performs", "a", "conditional", "assignment", "." ]
87842ae295c2283d8e02d951781189486a7cc970
https://github.com/YorickPeterse/ruby-lint/blob/87842ae295c2283d8e02d951781189486a7cc970/lib/ruby-lint/virtual_machine.rb#L1050-L1060
train
YorickPeterse/ruby-lint
lib/ruby-lint/virtual_machine.rb
RubyLint.VirtualMachine.definition_for_node
def definition_for_node(node) if node.const? and node.children[0] definition = ConstantPath.new(node).resolve(current_scope) else definition = current_scope.lookup(node.type, node.name) end definition = Definition::RubyObject.create_unknown unless definition return definition end
ruby
def definition_for_node(node) if node.const? and node.children[0] definition = ConstantPath.new(node).resolve(current_scope) else definition = current_scope.lookup(node.type, node.name) end definition = Definition::RubyObject.create_unknown unless definition return definition end
[ "def", "definition_for_node", "(", "node", ")", "if", "node", ".", "const?", "and", "node", ".", "children", "[", "0", "]", "definition", "=", "ConstantPath", ".", "new", "(", "node", ")", ".", "resolve", "(", "current_scope", ")", "else", "definition", "=", "current_scope", ".", "lookup", "(", "node", ".", "type", ",", "node", ".", "name", ")", "end", "definition", "=", "Definition", "::", "RubyObject", ".", "create_unknown", "unless", "definition", "return", "definition", "end" ]
Returns the definition for the given node. @param [RubyLint::AST::Node] node @return [RubyLint::Definition::RubyObject]
[ "Returns", "the", "definition", "for", "the", "given", "node", "." ]
87842ae295c2283d8e02d951781189486a7cc970
https://github.com/YorickPeterse/ruby-lint/blob/87842ae295c2283d8e02d951781189486a7cc970/lib/ruby-lint/virtual_machine.rb#L1068-L1078
train
YorickPeterse/ruby-lint
lib/ruby-lint/virtual_machine.rb
RubyLint.VirtualMachine.increment_reference_amount
def increment_reference_amount(node) definition = definition_for_node(node) if definition and !definition.frozen? definition.reference_amount += 1 end end
ruby
def increment_reference_amount(node) definition = definition_for_node(node) if definition and !definition.frozen? definition.reference_amount += 1 end end
[ "def", "increment_reference_amount", "(", "node", ")", "definition", "=", "definition_for_node", "(", "node", ")", "if", "definition", "and", "!", "definition", ".", "frozen?", "definition", ".", "reference_amount", "+=", "1", "end", "end" ]
Increments the reference amount of a node's definition unless the definition is frozen. @param [RubyLint::AST::Node] node
[ "Increments", "the", "reference", "amount", "of", "a", "node", "s", "definition", "unless", "the", "definition", "is", "frozen", "." ]
87842ae295c2283d8e02d951781189486a7cc970
https://github.com/YorickPeterse/ruby-lint/blob/87842ae295c2283d8e02d951781189486a7cc970/lib/ruby-lint/virtual_machine.rb#L1086-L1092
train
YorickPeterse/ruby-lint
lib/ruby-lint/virtual_machine.rb
RubyLint.VirtualMachine.inherit_definition
def inherit_definition(definition, inherit) unless definition.parents.include?(inherit) definition.parents << inherit end end
ruby
def inherit_definition(definition, inherit) unless definition.parents.include?(inherit) definition.parents << inherit end end
[ "def", "inherit_definition", "(", "definition", ",", "inherit", ")", "unless", "definition", ".", "parents", ".", "include?", "(", "inherit", ")", "definition", ".", "parents", "<<", "inherit", "end", "end" ]
Includes the definition `inherit` in the list of parent definitions of `definition`. @param [RubyLint::Definition::RubyObject] definition @param [RubyLint::Definition::RubyObject] inherit
[ "Includes", "the", "definition", "inherit", "in", "the", "list", "of", "parent", "definitions", "of", "definition", "." ]
87842ae295c2283d8e02d951781189486a7cc970
https://github.com/YorickPeterse/ruby-lint/blob/87842ae295c2283d8e02d951781189486a7cc970/lib/ruby-lint/virtual_machine.rb#L1101-L1105
train
YorickPeterse/ruby-lint
lib/ruby-lint/virtual_machine.rb
RubyLint.VirtualMachine.buffer_docstring_tags
def buffer_docstring_tags(node) return unless comments[node] parser = Docstring::Parser.new tags = parser.parse(comments[node].map(&:text)) @docstring_tags = Docstring::Mapping.new(tags) end
ruby
def buffer_docstring_tags(node) return unless comments[node] parser = Docstring::Parser.new tags = parser.parse(comments[node].map(&:text)) @docstring_tags = Docstring::Mapping.new(tags) end
[ "def", "buffer_docstring_tags", "(", "node", ")", "return", "unless", "comments", "[", "node", "]", "parser", "=", "Docstring", "::", "Parser", ".", "new", "tags", "=", "parser", ".", "parse", "(", "comments", "[", "node", "]", ".", "map", "(", "&", ":text", ")", ")", "@docstring_tags", "=", "Docstring", "::", "Mapping", ".", "new", "(", "tags", ")", "end" ]
Extracts all the docstring tags from the documentation of the given node, retrieves the corresponding types and stores them for later use. @param [RubyLint::AST::Node] node
[ "Extracts", "all", "the", "docstring", "tags", "from", "the", "documentation", "of", "the", "given", "node", "retrieves", "the", "corresponding", "types", "and", "stores", "them", "for", "later", "use", "." ]
87842ae295c2283d8e02d951781189486a7cc970
https://github.com/YorickPeterse/ruby-lint/blob/87842ae295c2283d8e02d951781189486a7cc970/lib/ruby-lint/virtual_machine.rb#L1113-L1120
train
YorickPeterse/ruby-lint
lib/ruby-lint/virtual_machine.rb
RubyLint.VirtualMachine.create_unknown_with_method
def create_unknown_with_method(name) definition = Definition::RubyObject.create_unknown definition.send("define_#{@method_type}", name) return definition end
ruby
def create_unknown_with_method(name) definition = Definition::RubyObject.create_unknown definition.send("define_#{@method_type}", name) return definition end
[ "def", "create_unknown_with_method", "(", "name", ")", "definition", "=", "Definition", "::", "RubyObject", ".", "create_unknown", "definition", ".", "send", "(", "\"define_#{@method_type}\"", ",", "name", ")", "return", "definition", "end" ]
Creates an "unknown" definition with the given method in it. @param [String] name The name of the method to add. @return [RubyLint::Definition::RubyObject]
[ "Creates", "an", "unknown", "definition", "with", "the", "given", "method", "in", "it", "." ]
87842ae295c2283d8e02d951781189486a7cc970
https://github.com/YorickPeterse/ruby-lint/blob/87842ae295c2283d8e02d951781189486a7cc970/lib/ruby-lint/virtual_machine.rb#L1148-L1154
train
YorickPeterse/ruby-lint
lib/ruby-lint/virtual_machine.rb
RubyLint.VirtualMachine.definitions_for_types
def definitions_for_types(types) definitions = [] # There are basically two type signatures: either the name(s) of a # constant or a method in the form of `#method_name`. types.each do |type| if type[0] == '#' found = create_unknown_with_method(type[1..-1]) else found = lookup_type_definition(type) end definitions << found if found end return definitions end
ruby
def definitions_for_types(types) definitions = [] # There are basically two type signatures: either the name(s) of a # constant or a method in the form of `#method_name`. types.each do |type| if type[0] == '#' found = create_unknown_with_method(type[1..-1]) else found = lookup_type_definition(type) end definitions << found if found end return definitions end
[ "def", "definitions_for_types", "(", "types", ")", "definitions", "=", "[", "]", "types", ".", "each", "do", "|", "type", "|", "if", "type", "[", "0", "]", "==", "'#'", "found", "=", "create_unknown_with_method", "(", "type", "[", "1", "..", "-", "1", "]", ")", "else", "found", "=", "lookup_type_definition", "(", "type", ")", "end", "definitions", "<<", "found", "if", "found", "end", "return", "definitions", "end" ]
Returns a collection of definitions for a set of YARD types. @param [Array] types @return [Array]
[ "Returns", "a", "collection", "of", "definitions", "for", "a", "set", "of", "YARD", "types", "." ]
87842ae295c2283d8e02d951781189486a7cc970
https://github.com/YorickPeterse/ruby-lint/blob/87842ae295c2283d8e02d951781189486a7cc970/lib/ruby-lint/virtual_machine.rb#L1162-L1178
train
YorickPeterse/ruby-lint
lib/ruby-lint/virtual_machine.rb
RubyLint.VirtualMachine.track_method_call
def track_method_call(definition, name, node) method = definition.lookup(definition.method_call_type, name) current = current_scope location = { :line => node.line, :column => node.column, :file => node.file } # Add the call to the current scope if we're dealing with a writable # method definition. if current.respond_to?(:calls) and !current.frozen? current.calls.push( MethodCallInfo.new(location.merge(:definition => method)) ) end # Add the caller to the called method, this allows for inverse lookups. unless method.frozen? method.callers.push( MethodCallInfo.new(location.merge(:definition => definition)) ) end end
ruby
def track_method_call(definition, name, node) method = definition.lookup(definition.method_call_type, name) current = current_scope location = { :line => node.line, :column => node.column, :file => node.file } # Add the call to the current scope if we're dealing with a writable # method definition. if current.respond_to?(:calls) and !current.frozen? current.calls.push( MethodCallInfo.new(location.merge(:definition => method)) ) end # Add the caller to the called method, this allows for inverse lookups. unless method.frozen? method.callers.push( MethodCallInfo.new(location.merge(:definition => definition)) ) end end
[ "def", "track_method_call", "(", "definition", ",", "name", ",", "node", ")", "method", "=", "definition", ".", "lookup", "(", "definition", ".", "method_call_type", ",", "name", ")", "current", "=", "current_scope", "location", "=", "{", ":line", "=>", "node", ".", "line", ",", ":column", "=>", "node", ".", "column", ",", ":file", "=>", "node", ".", "file", "}", "if", "current", ".", "respond_to?", "(", ":calls", ")", "and", "!", "current", ".", "frozen?", "current", ".", "calls", ".", "push", "(", "MethodCallInfo", ".", "new", "(", "location", ".", "merge", "(", ":definition", "=>", "method", ")", ")", ")", "end", "unless", "method", ".", "frozen?", "method", ".", "callers", ".", "push", "(", "MethodCallInfo", ".", "new", "(", "location", ".", "merge", "(", ":definition", "=>", "definition", ")", ")", ")", "end", "end" ]
Tracks a method call. @param [RubyLint::Definition::RubyMethod] definition @param [String] name @param [RubyLint::AST::Node] node
[ "Tracks", "a", "method", "call", "." ]
87842ae295c2283d8e02d951781189486a7cc970
https://github.com/YorickPeterse/ruby-lint/blob/87842ae295c2283d8e02d951781189486a7cc970/lib/ruby-lint/virtual_machine.rb#L1211-L1234
train
YorickPeterse/ruby-lint
lib/ruby-lint/definition_generator.rb
RubyLint.DefinitionGenerator.group_constants
def group_constants(constants) grouped = Hash.new { |hash, key| hash[key] = [] } constants.each do |name| root = name.split('::')[0] grouped[root] << name end return grouped end
ruby
def group_constants(constants) grouped = Hash.new { |hash, key| hash[key] = [] } constants.each do |name| root = name.split('::')[0] grouped[root] << name end return grouped end
[ "def", "group_constants", "(", "constants", ")", "grouped", "=", "Hash", ".", "new", "{", "|", "hash", ",", "key", "|", "hash", "[", "key", "]", "=", "[", "]", "}", "constants", ".", "each", "do", "|", "name", "|", "root", "=", "name", ".", "split", "(", "'::'", ")", "[", "0", "]", "grouped", "[", "root", "]", "<<", "name", "end", "return", "grouped", "end" ]
Groups constants together based on the top level namespace segment. @param [Array] constants @return [Hash]
[ "Groups", "constants", "together", "based", "on", "the", "top", "level", "namespace", "segment", "." ]
87842ae295c2283d8e02d951781189486a7cc970
https://github.com/YorickPeterse/ruby-lint/blob/87842ae295c2283d8e02d951781189486a7cc970/lib/ruby-lint/definition_generator.rb#L115-L124
train
YorickPeterse/ruby-lint
lib/ruby-lint/definition_generator.rb
RubyLint.DefinitionGenerator.method_information
def method_information(inspected) arg_mapping = argument_mapping info = {:method => {}, :instance_method => {}} inspected.each do |type, methods| methods.each do |method| args = [] method.parameters.each_with_index do |arg, index| name = arg[1] || "arg#{index + 1}" args << {:type => arg_mapping[arg[0]], :name => name} end info[type][method.name] = args end end return info end
ruby
def method_information(inspected) arg_mapping = argument_mapping info = {:method => {}, :instance_method => {}} inspected.each do |type, methods| methods.each do |method| args = [] method.parameters.each_with_index do |arg, index| name = arg[1] || "arg#{index + 1}" args << {:type => arg_mapping[arg[0]], :name => name} end info[type][method.name] = args end end return info end
[ "def", "method_information", "(", "inspected", ")", "arg_mapping", "=", "argument_mapping", "info", "=", "{", ":method", "=>", "{", "}", ",", ":instance_method", "=>", "{", "}", "}", "inspected", ".", "each", "do", "|", "type", ",", "methods", "|", "methods", ".", "each", "do", "|", "method", "|", "args", "=", "[", "]", "method", ".", "parameters", ".", "each_with_index", "do", "|", "arg", ",", "index", "|", "name", "=", "arg", "[", "1", "]", "||", "\"arg#{index + 1}\"", "args", "<<", "{", ":type", "=>", "arg_mapping", "[", "arg", "[", "0", "]", "]", ",", ":name", "=>", "name", "}", "end", "info", "[", "type", "]", "[", "method", ".", "name", "]", "=", "args", "end", "end", "return", "info", "end" ]
Returns a Hash containing all the instance and class methods and their arguments. @param [Hash] inspected @return [Hash]
[ "Returns", "a", "Hash", "containing", "all", "the", "instance", "and", "class", "methods", "and", "their", "arguments", "." ]
87842ae295c2283d8e02d951781189486a7cc970
https://github.com/YorickPeterse/ruby-lint/blob/87842ae295c2283d8e02d951781189486a7cc970/lib/ruby-lint/definition_generator.rb#L151-L169
train
rvm/rvm-capistrano
lib/rvm/capistrano/helpers/rvm_methods.rb
Capistrano.RvmMethods.rvm_task
def rvm_task(name,&block) if fetch(:rvm_require_role,nil).nil? task name, &block else task name, :roles => fetch(:rvm_require_role), &block end end
ruby
def rvm_task(name,&block) if fetch(:rvm_require_role,nil).nil? task name, &block else task name, :roles => fetch(:rvm_require_role), &block end end
[ "def", "rvm_task", "(", "name", ",", "&", "block", ")", "if", "fetch", "(", ":rvm_require_role", ",", "nil", ")", ".", "nil?", "task", "name", ",", "&", "block", "else", "task", "name", ",", ":roles", "=>", "fetch", "(", ":rvm_require_role", ")", ",", "&", "block", "end", "end" ]
defined depending on which selector was used
[ "defined", "depending", "on", "which", "selector", "was", "used" ]
61eda4140db1d80c3cb4755ab0812752620fdf66
https://github.com/rvm/rvm-capistrano/blob/61eda4140db1d80c3cb4755ab0812752620fdf66/lib/rvm/capistrano/helpers/rvm_methods.rb#L4-L10
train
rvm/rvm-capistrano
lib/rvm/capistrano/helpers/rvm_methods.rb
Capistrano.RvmMethods.rvm_user_command
def rvm_user_command(options={}) return '' unless rvm_type == :mixed && options[:subject_class] rvm_user_args = rvm_user.empty? ? 'none' : rvm_user.map(&:to_s).join(' ') rvm_bin = path_to_bin_rvm({ :with_ruby => true }.merge(options)) "#{rvm_bin} rvm user #{rvm_user_args} ; " end
ruby
def rvm_user_command(options={}) return '' unless rvm_type == :mixed && options[:subject_class] rvm_user_args = rvm_user.empty? ? 'none' : rvm_user.map(&:to_s).join(' ') rvm_bin = path_to_bin_rvm({ :with_ruby => true }.merge(options)) "#{rvm_bin} rvm user #{rvm_user_args} ; " end
[ "def", "rvm_user_command", "(", "options", "=", "{", "}", ")", "return", "''", "unless", "rvm_type", "==", ":mixed", "&&", "options", "[", ":subject_class", "]", "rvm_user_args", "=", "rvm_user", ".", "empty?", "?", "'none'", ":", "rvm_user", ".", "map", "(", "&", ":to_s", ")", ".", "join", "(", "' '", ")", "rvm_bin", "=", "path_to_bin_rvm", "(", "{", ":with_ruby", "=>", "true", "}", ".", "merge", "(", "options", ")", ")", "\"#{rvm_bin} rvm user #{rvm_user_args} ; \"", "end" ]
If we're operating on something affected by the rvm user mode, we need to make sure that the server has the right rvm user mode. This returns a shell command to prepend to an existing command in order to achieve this.
[ "If", "we", "re", "operating", "on", "something", "affected", "by", "the", "rvm", "user", "mode", "we", "need", "to", "make", "sure", "that", "the", "server", "has", "the", "right", "rvm", "user", "mode", ".", "This", "returns", "a", "shell", "command", "to", "prepend", "to", "an", "existing", "command", "in", "order", "to", "achieve", "this", "." ]
61eda4140db1d80c3cb4755ab0812752620fdf66
https://github.com/rvm/rvm-capistrano/blob/61eda4140db1d80c3cb4755ab0812752620fdf66/lib/rvm/capistrano/helpers/rvm_methods.rb#L42-L47
train
cxn03651/writeexcel
lib/writeexcel/chart.rb
Writeexcel.Chart.set_x_axis
def set_x_axis(params) name, encoding = encode_utf16(params[:name], params[:name_encoding]) formula = parse_series_formula(params[:name_formula]) @x_axis_name = name @x_axis_encoding = encoding @x_axis_formula = formula end
ruby
def set_x_axis(params) name, encoding = encode_utf16(params[:name], params[:name_encoding]) formula = parse_series_formula(params[:name_formula]) @x_axis_name = name @x_axis_encoding = encoding @x_axis_formula = formula end
[ "def", "set_x_axis", "(", "params", ")", "name", ",", "encoding", "=", "encode_utf16", "(", "params", "[", ":name", "]", ",", "params", "[", ":name_encoding", "]", ")", "formula", "=", "parse_series_formula", "(", "params", "[", ":name_formula", "]", ")", "@x_axis_name", "=", "name", "@x_axis_encoding", "=", "encoding", "@x_axis_formula", "=", "formula", "end" ]
Set the properties of the X-axis. The set_x_axis() method is used to set properties of the X axis. chart.set_x_axis(:name => 'Sample length (m)' ) The properties that can be set are: :name (optional) :name_formula (optional) * :name Set the name (title or caption) for the axis. The name is displayed below the X axis. This property is optional. The default is to have no axis name. chart.set_x_axis( :name => 'Sample length (m)' ) * :name_formula Optional, can be used to link the name to a worksheet cell. See "Chart names and links". chart.set_x_axis( :name => 'Sample length (m)', :name_formula => '=Sheet1!$A$1' ) Additional axis properties such as range, divisions and ticks will be made available in later releases.
[ "Set", "the", "properties", "of", "the", "X", "-", "axis", "." ]
d0345067c21b14a7141ba66b6752be8f4be379de
https://github.com/cxn03651/writeexcel/blob/d0345067c21b14a7141ba66b6752be8f4be379de/lib/writeexcel/chart.rb#L254-L261
train
cxn03651/writeexcel
lib/writeexcel/chart.rb
Writeexcel.Chart.set_y_axis
def set_y_axis(params) name, encoding = encode_utf16(params[:name], params[:name_encoding]) formula = parse_series_formula(params[:name_formula]) @y_axis_name = name @y_axis_encoding = encoding @y_axis_formula = formula end
ruby
def set_y_axis(params) name, encoding = encode_utf16(params[:name], params[:name_encoding]) formula = parse_series_formula(params[:name_formula]) @y_axis_name = name @y_axis_encoding = encoding @y_axis_formula = formula end
[ "def", "set_y_axis", "(", "params", ")", "name", ",", "encoding", "=", "encode_utf16", "(", "params", "[", ":name", "]", ",", "params", "[", ":name_encoding", "]", ")", "formula", "=", "parse_series_formula", "(", "params", "[", ":name_formula", "]", ")", "@y_axis_name", "=", "name", "@y_axis_encoding", "=", "encoding", "@y_axis_formula", "=", "formula", "end" ]
Set the properties of the Y-axis. The set_y_axis() method is used to set properties of the Y axis. chart.set_y_axis(:name => 'Sample weight (kg)' ) The properties that can be set are: :name (optional) :name_formula (optional) * :name Set the name (title or caption) for the axis. The name is displayed to the left of the Y axis. This property is optional. The default is to have no axis name. chart.set_y_axis(:name => 'Sample weight (kg)' ) * :name_formula Optional, can be used to link the name to a worksheet cell. See "Chart names and links". chart.set_y_axis( :name => 'Sample weight (kg)', :name_formula => '=Sheet1!$B$1' ) Additional axis properties such as range, divisions and ticks will be made available in later releases.
[ "Set", "the", "properties", "of", "the", "Y", "-", "axis", "." ]
d0345067c21b14a7141ba66b6752be8f4be379de
https://github.com/cxn03651/writeexcel/blob/d0345067c21b14a7141ba66b6752be8f4be379de/lib/writeexcel/chart.rb#L296-L303
train
cxn03651/writeexcel
lib/writeexcel/chart.rb
Writeexcel.Chart.set_plotarea
def set_plotarea(params = {}) return if params.empty? area = @plotarea # Set the plotarea visibility. if params.has_key?(:visible) area[:visible] = params[:visible] return if area[:visible] == 0 end # TODO. could move this out of if statement. area[:bg_color_index] = 0x08 # Set the chart background colour. if params.has_key?(:color) index, rgb = get_color_indices(params[:color]) if !index.nil? area[:fg_color_index] = index area[:fg_color_rgb] = rgb area[:bg_color_index] = 0x08 area[:bg_color_rgb] = 0x000000 end end # Set the border line colour. if params.has_key?(:line_color) index, rgb = get_color_indices(params[:line_color]) if !index.nil? area[:line_color_index] = index area[:line_color_rgb] = rgb end end # Set the border line pattern. if params.has_key?(:line_pattern) pattern = get_line_pattern(params[:line_pattern]) area[:line_pattern] = pattern end # Set the border line weight. if params.has_key?(:line_weight) weight = get_line_weight(params[:line_weight]) area[:line_weight] = weight end end
ruby
def set_plotarea(params = {}) return if params.empty? area = @plotarea # Set the plotarea visibility. if params.has_key?(:visible) area[:visible] = params[:visible] return if area[:visible] == 0 end # TODO. could move this out of if statement. area[:bg_color_index] = 0x08 # Set the chart background colour. if params.has_key?(:color) index, rgb = get_color_indices(params[:color]) if !index.nil? area[:fg_color_index] = index area[:fg_color_rgb] = rgb area[:bg_color_index] = 0x08 area[:bg_color_rgb] = 0x000000 end end # Set the border line colour. if params.has_key?(:line_color) index, rgb = get_color_indices(params[:line_color]) if !index.nil? area[:line_color_index] = index area[:line_color_rgb] = rgb end end # Set the border line pattern. if params.has_key?(:line_pattern) pattern = get_line_pattern(params[:line_pattern]) area[:line_pattern] = pattern end # Set the border line weight. if params.has_key?(:line_weight) weight = get_line_weight(params[:line_weight]) area[:line_weight] = weight end end
[ "def", "set_plotarea", "(", "params", "=", "{", "}", ")", "return", "if", "params", ".", "empty?", "area", "=", "@plotarea", "if", "params", ".", "has_key?", "(", ":visible", ")", "area", "[", ":visible", "]", "=", "params", "[", ":visible", "]", "return", "if", "area", "[", ":visible", "]", "==", "0", "end", "area", "[", ":bg_color_index", "]", "=", "0x08", "if", "params", ".", "has_key?", "(", ":color", ")", "index", ",", "rgb", "=", "get_color_indices", "(", "params", "[", ":color", "]", ")", "if", "!", "index", ".", "nil?", "area", "[", ":fg_color_index", "]", "=", "index", "area", "[", ":fg_color_rgb", "]", "=", "rgb", "area", "[", ":bg_color_index", "]", "=", "0x08", "area", "[", ":bg_color_rgb", "]", "=", "0x000000", "end", "end", "if", "params", ".", "has_key?", "(", ":line_color", ")", "index", ",", "rgb", "=", "get_color_indices", "(", "params", "[", ":line_color", "]", ")", "if", "!", "index", ".", "nil?", "area", "[", ":line_color_index", "]", "=", "index", "area", "[", ":line_color_rgb", "]", "=", "rgb", "end", "end", "if", "params", ".", "has_key?", "(", ":line_pattern", ")", "pattern", "=", "get_line_pattern", "(", "params", "[", ":line_pattern", "]", ")", "area", "[", ":line_pattern", "]", "=", "pattern", "end", "if", "params", ".", "has_key?", "(", ":line_weight", ")", "weight", "=", "get_line_weight", "(", "params", "[", ":line_weight", "]", ")", "area", "[", ":line_weight", "]", "=", "weight", "end", "end" ]
Set the properties of the chart plotarea.
[ "Set", "the", "properties", "of", "the", "chart", "plotarea", "." ]
d0345067c21b14a7141ba66b6752be8f4be379de
https://github.com/cxn03651/writeexcel/blob/d0345067c21b14a7141ba66b6752be8f4be379de/lib/writeexcel/chart.rb#L357-L402
train
cxn03651/writeexcel
lib/writeexcel/chart.rb
Writeexcel.Chart.close
def close # :nodoc: # Ignore any data that has been written so far since it is probably # from unwanted Worksheet method calls. @data = '' # TODO. Check for charts without a series? # Store the chart BOF. store_bof(0x0020) # Store the page header store_header # Store the page footer store_footer # Store the page horizontal centering store_hcenter # Store the page vertical centering store_vcenter # Store the left margin store_margin_left # Store the right margin store_margin_right # Store the top margin store_margin_top # Store the bottom margin store_margin_bottom # Store the page setup store_setup # Store the sheet password store_password # Start of Chart specific records. # Store the FBI font records. store_fbi(*@config[:font_numbers]) store_fbi(*@config[:font_series]) store_fbi(*@config[:font_title]) store_fbi(*@config[:font_axes]) # Ignore UNITS record. # Store the Chart sub-stream. store_chart_stream # Append the sheet dimensions store_dimensions # TODO add SINDEX and NUMBER records. store_window2 unless @embedded store_eof end
ruby
def close # :nodoc: # Ignore any data that has been written so far since it is probably # from unwanted Worksheet method calls. @data = '' # TODO. Check for charts without a series? # Store the chart BOF. store_bof(0x0020) # Store the page header store_header # Store the page footer store_footer # Store the page horizontal centering store_hcenter # Store the page vertical centering store_vcenter # Store the left margin store_margin_left # Store the right margin store_margin_right # Store the top margin store_margin_top # Store the bottom margin store_margin_bottom # Store the page setup store_setup # Store the sheet password store_password # Start of Chart specific records. # Store the FBI font records. store_fbi(*@config[:font_numbers]) store_fbi(*@config[:font_series]) store_fbi(*@config[:font_title]) store_fbi(*@config[:font_axes]) # Ignore UNITS record. # Store the Chart sub-stream. store_chart_stream # Append the sheet dimensions store_dimensions # TODO add SINDEX and NUMBER records. store_window2 unless @embedded store_eof end
[ "def", "close", "@data", "=", "''", "store_bof", "(", "0x0020", ")", "store_header", "store_footer", "store_hcenter", "store_vcenter", "store_margin_left", "store_margin_right", "store_margin_top", "store_margin_bottom", "store_setup", "store_password", "store_fbi", "(", "*", "@config", "[", ":font_numbers", "]", ")", "store_fbi", "(", "*", "@config", "[", ":font_series", "]", ")", "store_fbi", "(", "*", "@config", "[", ":font_title", "]", ")", "store_fbi", "(", "*", "@config", "[", ":font_axes", "]", ")", "store_chart_stream", "store_dimensions", "store_window2", "unless", "@embedded", "store_eof", "end" ]
Create and store the Chart data structures.
[ "Create", "and", "store", "the", "Chart", "data", "structures", "." ]
d0345067c21b14a7141ba66b6752be8f4be379de
https://github.com/cxn03651/writeexcel/blob/d0345067c21b14a7141ba66b6752be8f4be379de/lib/writeexcel/chart.rb#L521-L582
train
cxn03651/writeexcel
lib/writeexcel/chart.rb
Writeexcel.Chart.store_window2
def store_window2 # :nodoc: record = 0x023E # Record identifier length = 0x000A # Number of bytes to follow grbit = 0x0000 # Option flags rwTop = 0x0000 # Top visible row colLeft = 0x0000 # Leftmost visible column rgbHdr = 0x0000 # Row/col heading, grid color # The options flags that comprise grbit fDspFmla = 0 # 0 - bit fDspGrid = 0 # 1 fDspRwCol = 0 # 2 fFrozen = 0 # 3 fDspZeros = 0 # 4 fDefaultHdr = 0 # 5 fArabic = 0 # 6 fDspGuts = 0 # 7 fFrozenNoSplit = 0 # 0 - bit fSelected = selected? ? 1 : 0 # 1 fPaged = 0 # 2 fBreakPreview = 0 # 3 #<<< Perltidy ignore this. grbit = fDspFmla grbit |= fDspGrid << 1 grbit |= fDspRwCol << 2 grbit |= fFrozen << 3 grbit |= fDspZeros << 4 grbit |= fDefaultHdr << 5 grbit |= fArabic << 6 grbit |= fDspGuts << 7 grbit |= fFrozenNoSplit << 8 grbit |= fSelected << 9 grbit |= fPaged << 10 grbit |= fBreakPreview << 11 #>>> header = [record, length].pack("vv") data = [grbit, rwTop, colLeft, rgbHdr].pack("vvvV") append(header, data) end
ruby
def store_window2 # :nodoc: record = 0x023E # Record identifier length = 0x000A # Number of bytes to follow grbit = 0x0000 # Option flags rwTop = 0x0000 # Top visible row colLeft = 0x0000 # Leftmost visible column rgbHdr = 0x0000 # Row/col heading, grid color # The options flags that comprise grbit fDspFmla = 0 # 0 - bit fDspGrid = 0 # 1 fDspRwCol = 0 # 2 fFrozen = 0 # 3 fDspZeros = 0 # 4 fDefaultHdr = 0 # 5 fArabic = 0 # 6 fDspGuts = 0 # 7 fFrozenNoSplit = 0 # 0 - bit fSelected = selected? ? 1 : 0 # 1 fPaged = 0 # 2 fBreakPreview = 0 # 3 #<<< Perltidy ignore this. grbit = fDspFmla grbit |= fDspGrid << 1 grbit |= fDspRwCol << 2 grbit |= fFrozen << 3 grbit |= fDspZeros << 4 grbit |= fDefaultHdr << 5 grbit |= fArabic << 6 grbit |= fDspGuts << 7 grbit |= fFrozenNoSplit << 8 grbit |= fSelected << 9 grbit |= fPaged << 10 grbit |= fBreakPreview << 11 #>>> header = [record, length].pack("vv") data = [grbit, rwTop, colLeft, rgbHdr].pack("vvvV") append(header, data) end
[ "def", "store_window2", "record", "=", "0x023E", "length", "=", "0x000A", "grbit", "=", "0x0000", "rwTop", "=", "0x0000", "colLeft", "=", "0x0000", "rgbHdr", "=", "0x0000", "fDspFmla", "=", "0", "fDspGrid", "=", "0", "fDspRwCol", "=", "0", "fFrozen", "=", "0", "fDspZeros", "=", "0", "fDefaultHdr", "=", "0", "fArabic", "=", "0", "fDspGuts", "=", "0", "fFrozenNoSplit", "=", "0", "fSelected", "=", "selected?", "?", "1", ":", "0", "fPaged", "=", "0", "fBreakPreview", "=", "0", "grbit", "=", "fDspFmla", "grbit", "|=", "fDspGrid", "<<", "1", "grbit", "|=", "fDspRwCol", "<<", "2", "grbit", "|=", "fFrozen", "<<", "3", "grbit", "|=", "fDspZeros", "<<", "4", "grbit", "|=", "fDefaultHdr", "<<", "5", "grbit", "|=", "fArabic", "<<", "6", "grbit", "|=", "fDspGuts", "<<", "7", "grbit", "|=", "fFrozenNoSplit", "<<", "8", "grbit", "|=", "fSelected", "<<", "9", "grbit", "|=", "fPaged", "<<", "10", "grbit", "|=", "fBreakPreview", "<<", "11", "header", "=", "[", "record", ",", "length", "]", ".", "pack", "(", "\"vv\"", ")", "data", "=", "[", "grbit", ",", "rwTop", ",", "colLeft", ",", "rgbHdr", "]", ".", "pack", "(", "\"vvvV\"", ")", "append", "(", "header", ",", "data", ")", "end" ]
Write BIFF record Window2. Note, this overrides the parent Worksheet record because the Chart version of the record is smaller and is used mainly to indicate if the chart tab is selected or not.
[ "Write", "BIFF", "record", "Window2", ".", "Note", "this", "overrides", "the", "parent", "Worksheet", "record", "because", "the", "Chart", "version", "of", "the", "record", "is", "smaller", "and", "is", "used", "mainly", "to", "indicate", "if", "the", "chart", "tab", "is", "selected", "or", "not", "." ]
d0345067c21b14a7141ba66b6752be8f4be379de
https://github.com/cxn03651/writeexcel/blob/d0345067c21b14a7141ba66b6752be8f4be379de/lib/writeexcel/chart.rb#L604-L645
train
cxn03651/writeexcel
lib/writeexcel/chart.rb
Writeexcel.Chart.encode_utf16
def encode_utf16(str, encoding = 0) # :nodoc: # Exit if the $string isn't defined, i.e., hasn't been set by user. return [nil, nil] if str.nil? string = str.dup # Return if encoding is set, i.e., string has been manually encoded. #return ( undef, undef ) if $string == 1; ruby_19 { string = convert_to_ascii_if_ascii(string) } # Handle utf8 strings. if is_utf8?(string) string = utf8_to_16be(string) encoding = 1 end # Chart strings are limited to 255 characters. limit = encoding != 0 ? 255 * 2 : 255 if string.bytesize >= limit # truncate the string and raise a warning. string = string[0, limit] end [string, encoding] end
ruby
def encode_utf16(str, encoding = 0) # :nodoc: # Exit if the $string isn't defined, i.e., hasn't been set by user. return [nil, nil] if str.nil? string = str.dup # Return if encoding is set, i.e., string has been manually encoded. #return ( undef, undef ) if $string == 1; ruby_19 { string = convert_to_ascii_if_ascii(string) } # Handle utf8 strings. if is_utf8?(string) string = utf8_to_16be(string) encoding = 1 end # Chart strings are limited to 255 characters. limit = encoding != 0 ? 255 * 2 : 255 if string.bytesize >= limit # truncate the string and raise a warning. string = string[0, limit] end [string, encoding] end
[ "def", "encode_utf16", "(", "str", ",", "encoding", "=", "0", ")", "return", "[", "nil", ",", "nil", "]", "if", "str", ".", "nil?", "string", "=", "str", ".", "dup", "ruby_19", "{", "string", "=", "convert_to_ascii_if_ascii", "(", "string", ")", "}", "if", "is_utf8?", "(", "string", ")", "string", "=", "utf8_to_16be", "(", "string", ")", "encoding", "=", "1", "end", "limit", "=", "encoding", "!=", "0", "?", "255", "*", "2", ":", "255", "if", "string", ".", "bytesize", ">=", "limit", "string", "=", "string", "[", "0", ",", "limit", "]", "end", "[", "string", ",", "encoding", "]", "end" ]
Convert UTF8 strings used in the chart to UTF16.
[ "Convert", "UTF8", "strings", "used", "in", "the", "chart", "to", "UTF16", "." ]
d0345067c21b14a7141ba66b6752be8f4be379de
https://github.com/cxn03651/writeexcel/blob/d0345067c21b14a7141ba66b6752be8f4be379de/lib/writeexcel/chart.rb#L692-L717
train
cxn03651/writeexcel
lib/writeexcel/chart.rb
Writeexcel.Chart.get_color_indices
def get_color_indices(color) # :nodoc: invalid = 0x7FFF # return from Colors#get_color when color is invalid index = Colors.new.get_color(color) index = invalid if color.respond_to?(:coerce) && (color < 8 || color > 63) if index == invalid [nil, nil] else [index, get_color_rbg(index)] end end
ruby
def get_color_indices(color) # :nodoc: invalid = 0x7FFF # return from Colors#get_color when color is invalid index = Colors.new.get_color(color) index = invalid if color.respond_to?(:coerce) && (color < 8 || color > 63) if index == invalid [nil, nil] else [index, get_color_rbg(index)] end end
[ "def", "get_color_indices", "(", "color", ")", "invalid", "=", "0x7FFF", "index", "=", "Colors", ".", "new", ".", "get_color", "(", "color", ")", "index", "=", "invalid", "if", "color", ".", "respond_to?", "(", ":coerce", ")", "&&", "(", "color", "<", "8", "||", "color", ">", "63", ")", "if", "index", "==", "invalid", "[", "nil", ",", "nil", "]", "else", "[", "index", ",", "get_color_rbg", "(", "index", ")", "]", "end", "end" ]
Convert the user specified colour index or string to an colour index and RGB colour number.
[ "Convert", "the", "user", "specified", "colour", "index", "or", "string", "to", "an", "colour", "index", "and", "RGB", "colour", "number", "." ]
d0345067c21b14a7141ba66b6752be8f4be379de
https://github.com/cxn03651/writeexcel/blob/d0345067c21b14a7141ba66b6752be8f4be379de/lib/writeexcel/chart.rb#L723-L733
train
cxn03651/writeexcel
lib/writeexcel/chart.rb
Writeexcel.Chart.get_line_pattern
def get_line_pattern(value) # :nodoc: value = value.downcase if value.respond_to?(:to_str) default = 0 patterns = { 0 => 5, 1 => 0, 2 => 1, 3 => 2, 4 => 3, 5 => 4, 6 => 7, 7 => 6, 8 => 8, 'solid' => 0, 'dash' => 1, 'dot' => 2, 'dash-dot' => 3, 'dash-dot-dot' => 4, 'none' => 5, 'dark-gray' => 6, 'medium-gray' => 7, 'light-gray' => 8, } if patterns.has_key?(value) patterns[value] else default end end
ruby
def get_line_pattern(value) # :nodoc: value = value.downcase if value.respond_to?(:to_str) default = 0 patterns = { 0 => 5, 1 => 0, 2 => 1, 3 => 2, 4 => 3, 5 => 4, 6 => 7, 7 => 6, 8 => 8, 'solid' => 0, 'dash' => 1, 'dot' => 2, 'dash-dot' => 3, 'dash-dot-dot' => 4, 'none' => 5, 'dark-gray' => 6, 'medium-gray' => 7, 'light-gray' => 8, } if patterns.has_key?(value) patterns[value] else default end end
[ "def", "get_line_pattern", "(", "value", ")", "value", "=", "value", ".", "downcase", "if", "value", ".", "respond_to?", "(", ":to_str", ")", "default", "=", "0", "patterns", "=", "{", "0", "=>", "5", ",", "1", "=>", "0", ",", "2", "=>", "1", ",", "3", "=>", "2", ",", "4", "=>", "3", ",", "5", "=>", "4", ",", "6", "=>", "7", ",", "7", "=>", "6", ",", "8", "=>", "8", ",", "'solid'", "=>", "0", ",", "'dash'", "=>", "1", ",", "'dot'", "=>", "2", ",", "'dash-dot'", "=>", "3", ",", "'dash-dot-dot'", "=>", "4", ",", "'none'", "=>", "5", ",", "'dark-gray'", "=>", "6", ",", "'medium-gray'", "=>", "7", ",", "'light-gray'", "=>", "8", ",", "}", "if", "patterns", ".", "has_key?", "(", "value", ")", "patterns", "[", "value", "]", "else", "default", "end", "end" ]
Get the Excel chart index for line pattern that corresponds to the user defined value.
[ "Get", "the", "Excel", "chart", "index", "for", "line", "pattern", "that", "corresponds", "to", "the", "user", "defined", "value", "." ]
d0345067c21b14a7141ba66b6752be8f4be379de
https://github.com/cxn03651/writeexcel/blob/d0345067c21b14a7141ba66b6752be8f4be379de/lib/writeexcel/chart.rb#L754-L784
train
cxn03651/writeexcel
lib/writeexcel/chart.rb
Writeexcel.Chart.get_line_weight
def get_line_weight(value) # :nodoc: value = value.downcase if value.respond_to?(:to_str) default = 0 weights = { 1 => -1, 2 => 0, 3 => 1, 4 => 2, 'hairline' => -1, 'narrow' => 0, 'medium' => 1, 'wide' => 2, } if weights.has_key?(value) weights[value] else default end end
ruby
def get_line_weight(value) # :nodoc: value = value.downcase if value.respond_to?(:to_str) default = 0 weights = { 1 => -1, 2 => 0, 3 => 1, 4 => 2, 'hairline' => -1, 'narrow' => 0, 'medium' => 1, 'wide' => 2, } if weights.has_key?(value) weights[value] else default end end
[ "def", "get_line_weight", "(", "value", ")", "value", "=", "value", ".", "downcase", "if", "value", ".", "respond_to?", "(", ":to_str", ")", "default", "=", "0", "weights", "=", "{", "1", "=>", "-", "1", ",", "2", "=>", "0", ",", "3", "=>", "1", ",", "4", "=>", "2", ",", "'hairline'", "=>", "-", "1", ",", "'narrow'", "=>", "0", ",", "'medium'", "=>", "1", ",", "'wide'", "=>", "2", ",", "}", "if", "weights", ".", "has_key?", "(", "value", ")", "weights", "[", "value", "]", "else", "default", "end", "end" ]
Get the Excel chart index for line weight that corresponds to the user defined value.
[ "Get", "the", "Excel", "chart", "index", "for", "line", "weight", "that", "corresponds", "to", "the", "user", "defined", "value", "." ]
d0345067c21b14a7141ba66b6752be8f4be379de
https://github.com/cxn03651/writeexcel/blob/d0345067c21b14a7141ba66b6752be8f4be379de/lib/writeexcel/chart.rb#L790-L810
train
cxn03651/writeexcel
lib/writeexcel/chart.rb
Writeexcel.Chart.store_chart_stream
def store_chart_stream # :nodoc: store_chart(*@config[:chart]) store_begin # Store the chart SCL record. store_plotgrowth if @chartarea[:visible] != 0 store_chartarea_frame_stream end # Store SERIES stream for each series. index = 0 @series.each do |series| store_series_stream( :index => index, :value_formula => series[:values][0], :value_count => series[:values][1], :category_count => series[:categories][1], :category_formula => series[:categories][0], :name => series[:name], :name_encoding => series[:name_encoding], :name_formula => series[:name_formula] ) index += 1 end store_shtprops # Write the TEXT streams. (5..6).each do |font_index| store_defaulttext store_series_text_stream(font_index) end store_axesused(1) store_axisparent_stream if !@title_name.nil? || !@title_formula.nil? store_title_text_stream end store_end end
ruby
def store_chart_stream # :nodoc: store_chart(*@config[:chart]) store_begin # Store the chart SCL record. store_plotgrowth if @chartarea[:visible] != 0 store_chartarea_frame_stream end # Store SERIES stream for each series. index = 0 @series.each do |series| store_series_stream( :index => index, :value_formula => series[:values][0], :value_count => series[:values][1], :category_count => series[:categories][1], :category_formula => series[:categories][0], :name => series[:name], :name_encoding => series[:name_encoding], :name_formula => series[:name_formula] ) index += 1 end store_shtprops # Write the TEXT streams. (5..6).each do |font_index| store_defaulttext store_series_text_stream(font_index) end store_axesused(1) store_axisparent_stream if !@title_name.nil? || !@title_formula.nil? store_title_text_stream end store_end end
[ "def", "store_chart_stream", "store_chart", "(", "*", "@config", "[", ":chart", "]", ")", "store_begin", "store_plotgrowth", "if", "@chartarea", "[", ":visible", "]", "!=", "0", "store_chartarea_frame_stream", "end", "index", "=", "0", "@series", ".", "each", "do", "|", "series", "|", "store_series_stream", "(", ":index", "=>", "index", ",", ":value_formula", "=>", "series", "[", ":values", "]", "[", "0", "]", ",", ":value_count", "=>", "series", "[", ":values", "]", "[", "1", "]", ",", ":category_count", "=>", "series", "[", ":categories", "]", "[", "1", "]", ",", ":category_formula", "=>", "series", "[", ":categories", "]", "[", "0", "]", ",", ":name", "=>", "series", "[", ":name", "]", ",", ":name_encoding", "=>", "series", "[", ":name_encoding", "]", ",", ":name_formula", "=>", "series", "[", ":name_formula", "]", ")", "index", "+=", "1", "end", "store_shtprops", "(", "5", "..", "6", ")", ".", "each", "do", "|", "font_index", "|", "store_defaulttext", "store_series_text_stream", "(", "font_index", ")", "end", "store_axesused", "(", "1", ")", "store_axisparent_stream", "if", "!", "@title_name", ".", "nil?", "||", "!", "@title_formula", ".", "nil?", "store_title_text_stream", "end", "store_end", "end" ]
Store the CHART record and it's substreams.
[ "Store", "the", "CHART", "record", "and", "it", "s", "substreams", "." ]
d0345067c21b14a7141ba66b6752be8f4be379de
https://github.com/cxn03651/writeexcel/blob/d0345067c21b14a7141ba66b6752be8f4be379de/lib/writeexcel/chart.rb#L815-L858
train
cxn03651/writeexcel
lib/writeexcel/chart.rb
Writeexcel.Chart.store_series_stream
def store_series_stream(params) # :nodoc: name_type = _formula_type_from_param(2, 1, params, :name_formula) value_type = _formula_type_from_param(2, 0, params, :value_formula) category_type = _formula_type_from_param(2, 0, params, :category_formula) store_series(params[:value_count], params[:category_count]) store_begin # Store the Series name AI record. store_ai(0, name_type, params[:name_formula]) unless params[:name].nil? store_seriestext(params[:name], params[:name_encoding]) end store_ai(1, value_type, params[:value_formula]) store_ai(2, category_type, params[:category_formula]) store_ai(3, 1, '' ) store_dataformat_stream(params[:index]) store_sertocrt store_end end
ruby
def store_series_stream(params) # :nodoc: name_type = _formula_type_from_param(2, 1, params, :name_formula) value_type = _formula_type_from_param(2, 0, params, :value_formula) category_type = _formula_type_from_param(2, 0, params, :category_formula) store_series(params[:value_count], params[:category_count]) store_begin # Store the Series name AI record. store_ai(0, name_type, params[:name_formula]) unless params[:name].nil? store_seriestext(params[:name], params[:name_encoding]) end store_ai(1, value_type, params[:value_formula]) store_ai(2, category_type, params[:category_formula]) store_ai(3, 1, '' ) store_dataformat_stream(params[:index]) store_sertocrt store_end end
[ "def", "store_series_stream", "(", "params", ")", "name_type", "=", "_formula_type_from_param", "(", "2", ",", "1", ",", "params", ",", ":name_formula", ")", "value_type", "=", "_formula_type_from_param", "(", "2", ",", "0", ",", "params", ",", ":value_formula", ")", "category_type", "=", "_formula_type_from_param", "(", "2", ",", "0", ",", "params", ",", ":category_formula", ")", "store_series", "(", "params", "[", ":value_count", "]", ",", "params", "[", ":category_count", "]", ")", "store_begin", "store_ai", "(", "0", ",", "name_type", ",", "params", "[", ":name_formula", "]", ")", "unless", "params", "[", ":name", "]", ".", "nil?", "store_seriestext", "(", "params", "[", ":name", "]", ",", "params", "[", ":name_encoding", "]", ")", "end", "store_ai", "(", "1", ",", "value_type", ",", "params", "[", ":value_formula", "]", ")", "store_ai", "(", "2", ",", "category_type", ",", "params", "[", ":category_formula", "]", ")", "store_ai", "(", "3", ",", "1", ",", "''", ")", "store_dataformat_stream", "(", "params", "[", ":index", "]", ")", "store_sertocrt", "store_end", "end" ]
Write the SERIES chart substream.
[ "Write", "the", "SERIES", "chart", "substream", "." ]
d0345067c21b14a7141ba66b6752be8f4be379de
https://github.com/cxn03651/writeexcel/blob/d0345067c21b14a7141ba66b6752be8f4be379de/lib/writeexcel/chart.rb#L870-L892
train
cxn03651/writeexcel
lib/writeexcel/chart.rb
Writeexcel.Chart.store_x_axis_text_stream
def store_x_axis_text_stream # :nodoc: formula = @x_axis_formula.nil? ? '' : @x_axis_formula ai_type = _formula_type(2, 1, formula) store_text(*@config[:x_axis_text]) store_begin store_pos(*@config[:x_axis_text_pos]) store_fontx(8) store_ai(0, ai_type, formula) unless @x_axis_name.nil? store_seriestext(@x_axis_name, @x_axis_encoding) end store_objectlink(3) store_end end
ruby
def store_x_axis_text_stream # :nodoc: formula = @x_axis_formula.nil? ? '' : @x_axis_formula ai_type = _formula_type(2, 1, formula) store_text(*@config[:x_axis_text]) store_begin store_pos(*@config[:x_axis_text_pos]) store_fontx(8) store_ai(0, ai_type, formula) unless @x_axis_name.nil? store_seriestext(@x_axis_name, @x_axis_encoding) end store_objectlink(3) store_end end
[ "def", "store_x_axis_text_stream", "formula", "=", "@x_axis_formula", ".", "nil?", "?", "''", ":", "@x_axis_formula", "ai_type", "=", "_formula_type", "(", "2", ",", "1", ",", "formula", ")", "store_text", "(", "*", "@config", "[", ":x_axis_text", "]", ")", "store_begin", "store_pos", "(", "*", "@config", "[", ":x_axis_text_pos", "]", ")", "store_fontx", "(", "8", ")", "store_ai", "(", "0", ",", "ai_type", ",", "formula", ")", "unless", "@x_axis_name", ".", "nil?", "store_seriestext", "(", "@x_axis_name", ",", "@x_axis_encoding", ")", "end", "store_objectlink", "(", "3", ")", "store_end", "end" ]
Write the X-axis TEXT substream.
[ "Write", "the", "X", "-", "axis", "TEXT", "substream", "." ]
d0345067c21b14a7141ba66b6752be8f4be379de
https://github.com/cxn03651/writeexcel/blob/d0345067c21b14a7141ba66b6752be8f4be379de/lib/writeexcel/chart.rb#L925-L942
train
cxn03651/writeexcel
lib/writeexcel/chart.rb
Writeexcel.Chart.store_axisparent_stream
def store_axisparent_stream # :nodoc: store_axisparent(*@config[:axisparent]) store_begin store_pos(*@config[:axisparent_pos]) store_axis_category_stream store_axis_values_stream if !@x_axis_name.nil? || !@x_axis_formula.nil? store_x_axis_text_stream end if !@y_axis_name.nil? || !@y_axis_formula.nil? store_y_axis_text_stream end if @plotarea[:visible] != 0 store_plotarea store_plotarea_frame_stream end store_chartformat_stream store_end end
ruby
def store_axisparent_stream # :nodoc: store_axisparent(*@config[:axisparent]) store_begin store_pos(*@config[:axisparent_pos]) store_axis_category_stream store_axis_values_stream if !@x_axis_name.nil? || !@x_axis_formula.nil? store_x_axis_text_stream end if !@y_axis_name.nil? || !@y_axis_formula.nil? store_y_axis_text_stream end if @plotarea[:visible] != 0 store_plotarea store_plotarea_frame_stream end store_chartformat_stream store_end end
[ "def", "store_axisparent_stream", "store_axisparent", "(", "*", "@config", "[", ":axisparent", "]", ")", "store_begin", "store_pos", "(", "*", "@config", "[", ":axisparent_pos", "]", ")", "store_axis_category_stream", "store_axis_values_stream", "if", "!", "@x_axis_name", ".", "nil?", "||", "!", "@x_axis_formula", ".", "nil?", "store_x_axis_text_stream", "end", "if", "!", "@y_axis_name", ".", "nil?", "||", "!", "@y_axis_formula", ".", "nil?", "store_y_axis_text_stream", "end", "if", "@plotarea", "[", ":visible", "]", "!=", "0", "store_plotarea", "store_plotarea_frame_stream", "end", "store_chartformat_stream", "store_end", "end" ]
Write the AXISPARENT chart substream.
[ "Write", "the", "AXISPARENT", "chart", "substream", "." ]
d0345067c21b14a7141ba66b6752be8f4be379de
https://github.com/cxn03651/writeexcel/blob/d0345067c21b14a7141ba66b6752be8f4be379de/lib/writeexcel/chart.rb#L1004-L1026
train
cxn03651/writeexcel
lib/writeexcel/chart.rb
Writeexcel.Chart.store_ai
def store_ai(id, type, formula, format_index = 0) # :nodoc: formula = '' if formula == [""] record = 0x1051 # Record identifier. length = 0x0008 # Number of bytes to follow. # id # Link index. # type # Reference type. # formula # Pre-parsed formula. # format_index # Num format index. grbit = 0x0000 # Option flags. ruby_19 { formula = convert_to_ascii_if_ascii(formula) } formula_length = formula.bytesize length += formula_length header = [record, length].pack('vv') data = [id].pack('C') data += [type].pack('C') data += [grbit].pack('v') data += [format_index].pack('v') data += [formula_length].pack('v') if formula.respond_to?(:to_array) data += ruby_18 { formula[0] } || ruby_19 { formula[0].encode('BINARY') } else data += ruby_18 { formula unless formula.nil? } || ruby_19 { formula.encode('BINARY') unless formula.nil? } end append(header, data) end
ruby
def store_ai(id, type, formula, format_index = 0) # :nodoc: formula = '' if formula == [""] record = 0x1051 # Record identifier. length = 0x0008 # Number of bytes to follow. # id # Link index. # type # Reference type. # formula # Pre-parsed formula. # format_index # Num format index. grbit = 0x0000 # Option flags. ruby_19 { formula = convert_to_ascii_if_ascii(formula) } formula_length = formula.bytesize length += formula_length header = [record, length].pack('vv') data = [id].pack('C') data += [type].pack('C') data += [grbit].pack('v') data += [format_index].pack('v') data += [formula_length].pack('v') if formula.respond_to?(:to_array) data += ruby_18 { formula[0] } || ruby_19 { formula[0].encode('BINARY') } else data += ruby_18 { formula unless formula.nil? } || ruby_19 { formula.encode('BINARY') unless formula.nil? } end append(header, data) end
[ "def", "store_ai", "(", "id", ",", "type", ",", "formula", ",", "format_index", "=", "0", ")", "formula", "=", "''", "if", "formula", "==", "[", "\"\"", "]", "record", "=", "0x1051", "length", "=", "0x0008", "grbit", "=", "0x0000", "ruby_19", "{", "formula", "=", "convert_to_ascii_if_ascii", "(", "formula", ")", "}", "formula_length", "=", "formula", ".", "bytesize", "length", "+=", "formula_length", "header", "=", "[", "record", ",", "length", "]", ".", "pack", "(", "'vv'", ")", "data", "=", "[", "id", "]", ".", "pack", "(", "'C'", ")", "data", "+=", "[", "type", "]", ".", "pack", "(", "'C'", ")", "data", "+=", "[", "grbit", "]", ".", "pack", "(", "'v'", ")", "data", "+=", "[", "format_index", "]", ".", "pack", "(", "'v'", ")", "data", "+=", "[", "formula_length", "]", ".", "pack", "(", "'v'", ")", "if", "formula", ".", "respond_to?", "(", ":to_array", ")", "data", "+=", "ruby_18", "{", "formula", "[", "0", "]", "}", "||", "ruby_19", "{", "formula", "[", "0", "]", ".", "encode", "(", "'BINARY'", ")", "}", "else", "data", "+=", "ruby_18", "{", "formula", "unless", "formula", ".", "nil?", "}", "||", "ruby_19", "{", "formula", ".", "encode", "(", "'BINARY'", ")", "unless", "formula", ".", "nil?", "}", "end", "append", "(", "header", ",", "data", ")", "end" ]
Write the AI chart BIFF record.
[ "Write", "the", "AI", "chart", "BIFF", "record", "." ]
d0345067c21b14a7141ba66b6752be8f4be379de
https://github.com/cxn03651/writeexcel/blob/d0345067c21b14a7141ba66b6752be8f4be379de/lib/writeexcel/chart.rb#L1171-L1204
train
cxn03651/writeexcel
lib/writeexcel/chart.rb
Writeexcel.Chart.store_areaformat
def store_areaformat(rgbFore, rgbBack, pattern, grbit, indexFore, indexBack) # :nodoc: record = 0x100A # Record identifier. length = 0x0010 # Number of bytes to follow. # rgbFore # Foreground RGB colour. # rgbBack # Background RGB colour. # pattern # Pattern. # grbit # Option flags. # indexFore # Index to Foreground colour. # indexBack # Index to Background colour. header = [record, length].pack('vv') data = [rgbFore].pack('V') data += [rgbBack].pack('V') data += [pattern].pack('v') data += [grbit].pack('v') data += [indexFore].pack('v') data += [indexBack].pack('v') append(header, data) end
ruby
def store_areaformat(rgbFore, rgbBack, pattern, grbit, indexFore, indexBack) # :nodoc: record = 0x100A # Record identifier. length = 0x0010 # Number of bytes to follow. # rgbFore # Foreground RGB colour. # rgbBack # Background RGB colour. # pattern # Pattern. # grbit # Option flags. # indexFore # Index to Foreground colour. # indexBack # Index to Background colour. header = [record, length].pack('vv') data = [rgbFore].pack('V') data += [rgbBack].pack('V') data += [pattern].pack('v') data += [grbit].pack('v') data += [indexFore].pack('v') data += [indexBack].pack('v') append(header, data) end
[ "def", "store_areaformat", "(", "rgbFore", ",", "rgbBack", ",", "pattern", ",", "grbit", ",", "indexFore", ",", "indexBack", ")", "record", "=", "0x100A", "length", "=", "0x0010", "header", "=", "[", "record", ",", "length", "]", ".", "pack", "(", "'vv'", ")", "data", "=", "[", "rgbFore", "]", ".", "pack", "(", "'V'", ")", "data", "+=", "[", "rgbBack", "]", ".", "pack", "(", "'V'", ")", "data", "+=", "[", "pattern", "]", ".", "pack", "(", "'v'", ")", "data", "+=", "[", "grbit", "]", ".", "pack", "(", "'v'", ")", "data", "+=", "[", "indexFore", "]", ".", "pack", "(", "'v'", ")", "data", "+=", "[", "indexBack", "]", ".", "pack", "(", "'v'", ")", "append", "(", "header", ",", "data", ")", "end" ]
Write the AREAFORMAT chart BIFF record. Contains the patterns and colours of a chart area.
[ "Write", "the", "AREAFORMAT", "chart", "BIFF", "record", ".", "Contains", "the", "patterns", "and", "colours", "of", "a", "chart", "area", "." ]
d0345067c21b14a7141ba66b6752be8f4be379de
https://github.com/cxn03651/writeexcel/blob/d0345067c21b14a7141ba66b6752be8f4be379de/lib/writeexcel/chart.rb#L1210-L1229
train
cxn03651/writeexcel
lib/writeexcel/chart.rb
Writeexcel.Chart.store_axcext
def store_axcext # :nodoc: record = 0x1062 # Record identifier. length = 0x0012 # Number of bytes to follow. catMin = 0x0000 # Minimum category on axis. catMax = 0x0000 # Maximum category on axis. catMajor = 0x0001 # Value of major unit. unitMajor = 0x0000 # Units of major unit. catMinor = 0x0001 # Value of minor unit. unitMinor = 0x0000 # Units of minor unit. unitBase = 0x0000 # Base unit of axis. catCrossDate = 0x0000 # Crossing point. grbit = 0x00EF # Option flags. store_simple(record, length, catMin, catMax, catMajor, unitMajor, catMinor, unitMinor, unitBase, catCrossDate, grbit) end
ruby
def store_axcext # :nodoc: record = 0x1062 # Record identifier. length = 0x0012 # Number of bytes to follow. catMin = 0x0000 # Minimum category on axis. catMax = 0x0000 # Maximum category on axis. catMajor = 0x0001 # Value of major unit. unitMajor = 0x0000 # Units of major unit. catMinor = 0x0001 # Value of minor unit. unitMinor = 0x0000 # Units of minor unit. unitBase = 0x0000 # Base unit of axis. catCrossDate = 0x0000 # Crossing point. grbit = 0x00EF # Option flags. store_simple(record, length, catMin, catMax, catMajor, unitMajor, catMinor, unitMinor, unitBase, catCrossDate, grbit) end
[ "def", "store_axcext", "record", "=", "0x1062", "length", "=", "0x0012", "catMin", "=", "0x0000", "catMax", "=", "0x0000", "catMajor", "=", "0x0001", "unitMajor", "=", "0x0000", "catMinor", "=", "0x0001", "unitMinor", "=", "0x0000", "unitBase", "=", "0x0000", "catCrossDate", "=", "0x0000", "grbit", "=", "0x00EF", "store_simple", "(", "record", ",", "length", ",", "catMin", ",", "catMax", ",", "catMajor", ",", "unitMajor", ",", "catMinor", ",", "unitMinor", ",", "unitBase", ",", "catCrossDate", ",", "grbit", ")", "end" ]
Write the AXCEXT chart BIFF record.
[ "Write", "the", "AXCEXT", "chart", "BIFF", "record", "." ]
d0345067c21b14a7141ba66b6752be8f4be379de
https://github.com/cxn03651/writeexcel/blob/d0345067c21b14a7141ba66b6752be8f4be379de/lib/writeexcel/chart.rb#L1234-L1249
train
cxn03651/writeexcel
lib/writeexcel/chart.rb
Writeexcel.Chart.store_axis
def store_axis(type) # :nodoc: record = 0x101D # Record identifier. length = 0x0012 # Number of bytes to follow. # type # Axis type. reserved1 = 0x00000000 # Reserved. reserved2 = 0x00000000 # Reserved. reserved3 = 0x00000000 # Reserved. reserved4 = 0x00000000 # Reserved. header = [record, length].pack('vv') data = [type].pack('v') data += [reserved1].pack('V') data += [reserved2].pack('V') data += [reserved3].pack('V') data += [reserved4].pack('V') append(header, data) end
ruby
def store_axis(type) # :nodoc: record = 0x101D # Record identifier. length = 0x0012 # Number of bytes to follow. # type # Axis type. reserved1 = 0x00000000 # Reserved. reserved2 = 0x00000000 # Reserved. reserved3 = 0x00000000 # Reserved. reserved4 = 0x00000000 # Reserved. header = [record, length].pack('vv') data = [type].pack('v') data += [reserved1].pack('V') data += [reserved2].pack('V') data += [reserved3].pack('V') data += [reserved4].pack('V') append(header, data) end
[ "def", "store_axis", "(", "type", ")", "record", "=", "0x101D", "length", "=", "0x0012", "reserved1", "=", "0x00000000", "reserved2", "=", "0x00000000", "reserved3", "=", "0x00000000", "reserved4", "=", "0x00000000", "header", "=", "[", "record", ",", "length", "]", ".", "pack", "(", "'vv'", ")", "data", "=", "[", "type", "]", ".", "pack", "(", "'v'", ")", "data", "+=", "[", "reserved1", "]", ".", "pack", "(", "'V'", ")", "data", "+=", "[", "reserved2", "]", ".", "pack", "(", "'V'", ")", "data", "+=", "[", "reserved3", "]", ".", "pack", "(", "'V'", ")", "data", "+=", "[", "reserved4", "]", ".", "pack", "(", "'V'", ")", "append", "(", "header", ",", "data", ")", "end" ]
Write the AXIS chart BIFF record to define the axis type.
[ "Write", "the", "AXIS", "chart", "BIFF", "record", "to", "define", "the", "axis", "type", "." ]
d0345067c21b14a7141ba66b6752be8f4be379de
https://github.com/cxn03651/writeexcel/blob/d0345067c21b14a7141ba66b6752be8f4be379de/lib/writeexcel/chart.rb#L1265-L1282
train
cxn03651/writeexcel
lib/writeexcel/chart.rb
Writeexcel.Chart.store_axisparent
def store_axisparent(iax, x, y, dx, dy) # :nodoc: record = 0x1041 # Record identifier. length = 0x0012 # Number of bytes to follow. # iax # Axis index. # x # X-coord. # y # Y-coord. # dx # Length of x axis. # dy # Length of y axis. header = [record, length].pack('vv') data = [iax].pack('v') data += [x].pack('V') data += [y].pack('V') data += [dx].pack('V') data += [dy].pack('V') append(header, data) end
ruby
def store_axisparent(iax, x, y, dx, dy) # :nodoc: record = 0x1041 # Record identifier. length = 0x0012 # Number of bytes to follow. # iax # Axis index. # x # X-coord. # y # Y-coord. # dx # Length of x axis. # dy # Length of y axis. header = [record, length].pack('vv') data = [iax].pack('v') data += [x].pack('V') data += [y].pack('V') data += [dx].pack('V') data += [dy].pack('V') append(header, data) end
[ "def", "store_axisparent", "(", "iax", ",", "x", ",", "y", ",", "dx", ",", "dy", ")", "record", "=", "0x1041", "length", "=", "0x0012", "header", "=", "[", "record", ",", "length", "]", ".", "pack", "(", "'vv'", ")", "data", "=", "[", "iax", "]", ".", "pack", "(", "'v'", ")", "data", "+=", "[", "x", "]", ".", "pack", "(", "'V'", ")", "data", "+=", "[", "y", "]", ".", "pack", "(", "'V'", ")", "data", "+=", "[", "dx", "]", ".", "pack", "(", "'V'", ")", "data", "+=", "[", "dy", "]", ".", "pack", "(", "'V'", ")", "append", "(", "header", ",", "data", ")", "end" ]
Write the AXISPARENT chart BIFF record.
[ "Write", "the", "AXISPARENT", "chart", "BIFF", "record", "." ]
d0345067c21b14a7141ba66b6752be8f4be379de
https://github.com/cxn03651/writeexcel/blob/d0345067c21b14a7141ba66b6752be8f4be379de/lib/writeexcel/chart.rb#L1298-L1315
train
cxn03651/writeexcel
lib/writeexcel/chart.rb
Writeexcel.Chart.store_catserrange
def store_catserrange # :nodoc: record = 0x1020 # Record identifier. length = 0x0008 # Number of bytes to follow. catCross = 0x0001 # Value/category crossing. catLabel = 0x0001 # Frequency of labels. catMark = 0x0001 # Frequency of ticks. grbit = 0x0001 # Option flags. store_simple(record, length, catCross, catLabel, catMark, grbit) end
ruby
def store_catserrange # :nodoc: record = 0x1020 # Record identifier. length = 0x0008 # Number of bytes to follow. catCross = 0x0001 # Value/category crossing. catLabel = 0x0001 # Frequency of labels. catMark = 0x0001 # Frequency of ticks. grbit = 0x0001 # Option flags. store_simple(record, length, catCross, catLabel, catMark, grbit) end
[ "def", "store_catserrange", "record", "=", "0x1020", "length", "=", "0x0008", "catCross", "=", "0x0001", "catLabel", "=", "0x0001", "catMark", "=", "0x0001", "grbit", "=", "0x0001", "store_simple", "(", "record", ",", "length", ",", "catCross", ",", "catLabel", ",", "catMark", ",", "grbit", ")", "end" ]
Write the CATSERRANGE chart BIFF record.
[ "Write", "the", "CATSERRANGE", "chart", "BIFF", "record", "." ]
d0345067c21b14a7141ba66b6752be8f4be379de
https://github.com/cxn03651/writeexcel/blob/d0345067c21b14a7141ba66b6752be8f4be379de/lib/writeexcel/chart.rb#L1330-L1339
train
cxn03651/writeexcel
lib/writeexcel/chart.rb
Writeexcel.Chart.store_chartformat
def store_chartformat(grbit = 0) # :nodoc: record = 0x1014 # Record identifier. length = 0x0014 # Number of bytes to follow. reserved1 = 0x00000000 # Reserved. reserved2 = 0x00000000 # Reserved. reserved3 = 0x00000000 # Reserved. reserved4 = 0x00000000 # Reserved. # grbit # Option flags. icrt = 0x0000 # Drawing order. header = [record, length].pack('vv') data = [reserved1].pack('V') data += [reserved2].pack('V') data += [reserved3].pack('V') data += [reserved4].pack('V') data += [grbit].pack('v') data += [icrt].pack('v') append(header, data) end
ruby
def store_chartformat(grbit = 0) # :nodoc: record = 0x1014 # Record identifier. length = 0x0014 # Number of bytes to follow. reserved1 = 0x00000000 # Reserved. reserved2 = 0x00000000 # Reserved. reserved3 = 0x00000000 # Reserved. reserved4 = 0x00000000 # Reserved. # grbit # Option flags. icrt = 0x0000 # Drawing order. header = [record, length].pack('vv') data = [reserved1].pack('V') data += [reserved2].pack('V') data += [reserved3].pack('V') data += [reserved4].pack('V') data += [grbit].pack('v') data += [icrt].pack('v') append(header, data) end
[ "def", "store_chartformat", "(", "grbit", "=", "0", ")", "record", "=", "0x1014", "length", "=", "0x0014", "reserved1", "=", "0x00000000", "reserved2", "=", "0x00000000", "reserved3", "=", "0x00000000", "reserved4", "=", "0x00000000", "icrt", "=", "0x0000", "header", "=", "[", "record", ",", "length", "]", ".", "pack", "(", "'vv'", ")", "data", "=", "[", "reserved1", "]", ".", "pack", "(", "'V'", ")", "data", "+=", "[", "reserved2", "]", ".", "pack", "(", "'V'", ")", "data", "+=", "[", "reserved3", "]", ".", "pack", "(", "'V'", ")", "data", "+=", "[", "reserved4", "]", ".", "pack", "(", "'V'", ")", "data", "+=", "[", "grbit", "]", ".", "pack", "(", "'v'", ")", "data", "+=", "[", "icrt", "]", ".", "pack", "(", "'v'", ")", "append", "(", "header", ",", "data", ")", "end" ]
Write the CHARTFORMAT chart BIFF record. The parent record for formatting of a chart group.
[ "Write", "the", "CHARTFORMAT", "chart", "BIFF", "record", ".", "The", "parent", "record", "for", "formatting", "of", "a", "chart", "group", "." ]
d0345067c21b14a7141ba66b6752be8f4be379de
https://github.com/cxn03651/writeexcel/blob/d0345067c21b14a7141ba66b6752be8f4be379de/lib/writeexcel/chart.rb#L1367-L1386
train
cxn03651/writeexcel
lib/writeexcel/chart.rb
Writeexcel.Chart.store_dataformat
def store_dataformat(series_index, series_number, point_number) # :nodoc: record = 0x1006 # Record identifier. length = 0x0008 # Number of bytes to follow. # series_index # Series index. # series_number # Series number. (Same as index). # point_number # Point number. grbit = 0x0000 # Format flags. store_simple(record, length, point_number, series_index, series_number, grbit) end
ruby
def store_dataformat(series_index, series_number, point_number) # :nodoc: record = 0x1006 # Record identifier. length = 0x0008 # Number of bytes to follow. # series_index # Series index. # series_number # Series number. (Same as index). # point_number # Point number. grbit = 0x0000 # Format flags. store_simple(record, length, point_number, series_index, series_number, grbit) end
[ "def", "store_dataformat", "(", "series_index", ",", "series_number", ",", "point_number", ")", "record", "=", "0x1006", "length", "=", "0x0008", "grbit", "=", "0x0000", "store_simple", "(", "record", ",", "length", ",", "point_number", ",", "series_index", ",", "series_number", ",", "grbit", ")", "end" ]
Write the DATAFORMAT chart BIFF record. This record specifies the series that the subsequent sub stream refers to.
[ "Write", "the", "DATAFORMAT", "chart", "BIFF", "record", ".", "This", "record", "specifies", "the", "series", "that", "the", "subsequent", "sub", "stream", "refers", "to", "." ]
d0345067c21b14a7141ba66b6752be8f4be379de
https://github.com/cxn03651/writeexcel/blob/d0345067c21b14a7141ba66b6752be8f4be379de/lib/writeexcel/chart.rb#L1439-L1448
train
cxn03651/writeexcel
lib/writeexcel/chart.rb
Writeexcel.Chart.store_fbi
def store_fbi(index, height, width_basis, height_basis, scale_basis) # :nodoc: record = 0x1060 # Record identifier. length = 0x000A # Number of bytes to follow. # index # Font index. height = height * 20 # Default font height in twips. # width_basis # Width basis, in twips. # height_basis # Height basis, in twips. # scale_basis # Scale by chart area or plot area. store_simple(record, length, width_basis, height_basis, height, scale_basis, index) end
ruby
def store_fbi(index, height, width_basis, height_basis, scale_basis) # :nodoc: record = 0x1060 # Record identifier. length = 0x000A # Number of bytes to follow. # index # Font index. height = height * 20 # Default font height in twips. # width_basis # Width basis, in twips. # height_basis # Height basis, in twips. # scale_basis # Scale by chart area or plot area. store_simple(record, length, width_basis, height_basis, height, scale_basis, index) end
[ "def", "store_fbi", "(", "index", ",", "height", ",", "width_basis", ",", "height_basis", ",", "scale_basis", ")", "record", "=", "0x1060", "length", "=", "0x000A", "height", "=", "height", "*", "20", "store_simple", "(", "record", ",", "length", ",", "width_basis", ",", "height_basis", ",", "height", ",", "scale_basis", ",", "index", ")", "end" ]
Write the FBI chart BIFF record. Specifies the font information at the time it was applied to the chart.
[ "Write", "the", "FBI", "chart", "BIFF", "record", ".", "Specifies", "the", "font", "information", "at", "the", "time", "it", "was", "applied", "to", "the", "chart", "." ]
d0345067c21b14a7141ba66b6752be8f4be379de
https://github.com/cxn03651/writeexcel/blob/d0345067c21b14a7141ba66b6752be8f4be379de/lib/writeexcel/chart.rb#L1487-L1497
train
cxn03651/writeexcel
lib/writeexcel/chart.rb
Writeexcel.Chart.store_frame
def store_frame(frame_type, grbit) # :nodoc: record = 0x1032 # Record identifier. length = 0x0004 # Number of bytes to follow. # frame_type # Frame type. # grbit # Option flags. store_simple(record, length, frame_type, grbit) end
ruby
def store_frame(frame_type, grbit) # :nodoc: record = 0x1032 # Record identifier. length = 0x0004 # Number of bytes to follow. # frame_type # Frame type. # grbit # Option flags. store_simple(record, length, frame_type, grbit) end
[ "def", "store_frame", "(", "frame_type", ",", "grbit", ")", "record", "=", "0x1032", "length", "=", "0x0004", "store_simple", "(", "record", ",", "length", ",", "frame_type", ",", "grbit", ")", "end" ]
Write the FRAME chart BIFF record.
[ "Write", "the", "FRAME", "chart", "BIFF", "record", "." ]
d0345067c21b14a7141ba66b6752be8f4be379de
https://github.com/cxn03651/writeexcel/blob/d0345067c21b14a7141ba66b6752be8f4be379de/lib/writeexcel/chart.rb#L1514-L1521
train
cxn03651/writeexcel
lib/writeexcel/chart.rb
Writeexcel.Chart.store_legend
def store_legend(x, y, width, height, wType, wSpacing, grbit) # :nodoc: record = 0x1015 # Record identifier. length = 0x0014 # Number of bytes to follow. # x # X-position. # y # Y-position. # width # Width. # height # Height. # wType # Type. # wSpacing # Spacing. # grbit # Option flags. header = [record, length].pack('vv') data = [x].pack('V') data += [y].pack('V') data += [width].pack('V') data += [height].pack('V') data += [wType].pack('C') data += [wSpacing].pack('C') data += [grbit].pack('v') append(header, data) end
ruby
def store_legend(x, y, width, height, wType, wSpacing, grbit) # :nodoc: record = 0x1015 # Record identifier. length = 0x0014 # Number of bytes to follow. # x # X-position. # y # Y-position. # width # Width. # height # Height. # wType # Type. # wSpacing # Spacing. # grbit # Option flags. header = [record, length].pack('vv') data = [x].pack('V') data += [y].pack('V') data += [width].pack('V') data += [height].pack('V') data += [wType].pack('C') data += [wSpacing].pack('C') data += [grbit].pack('v') append(header, data) end
[ "def", "store_legend", "(", "x", ",", "y", ",", "width", ",", "height", ",", "wType", ",", "wSpacing", ",", "grbit", ")", "record", "=", "0x1015", "length", "=", "0x0014", "header", "=", "[", "record", ",", "length", "]", ".", "pack", "(", "'vv'", ")", "data", "=", "[", "x", "]", ".", "pack", "(", "'V'", ")", "data", "+=", "[", "y", "]", ".", "pack", "(", "'V'", ")", "data", "+=", "[", "width", "]", ".", "pack", "(", "'V'", ")", "data", "+=", "[", "height", "]", ".", "pack", "(", "'V'", ")", "data", "+=", "[", "wType", "]", ".", "pack", "(", "'C'", ")", "data", "+=", "[", "wSpacing", "]", ".", "pack", "(", "'C'", ")", "data", "+=", "[", "grbit", "]", ".", "pack", "(", "'v'", ")", "append", "(", "header", ",", "data", ")", "end" ]
Write the LEGEND chart BIFF record. The Marcus Horan method.
[ "Write", "the", "LEGEND", "chart", "BIFF", "record", ".", "The", "Marcus", "Horan", "method", "." ]
d0345067c21b14a7141ba66b6752be8f4be379de
https://github.com/cxn03651/writeexcel/blob/d0345067c21b14a7141ba66b6752be8f4be379de/lib/writeexcel/chart.rb#L1526-L1547
train
cxn03651/writeexcel
lib/writeexcel/chart.rb
Writeexcel.Chart.store_lineformat
def store_lineformat(rgb, lns, we, grbit, index) # :nodoc: record = 0x1007 # Record identifier. length = 0x000C # Number of bytes to follow. # rgb # Line RGB colour. # lns # Line pattern. # we # Line weight. # grbit # Option flags. # index # Index to colour of line. header = [record, length].pack('vv') data = [rgb].pack('V') data += [lns].pack('v') data += [we].pack('v') data += [grbit].pack('v') data += [index].pack('v') append(header, data) end
ruby
def store_lineformat(rgb, lns, we, grbit, index) # :nodoc: record = 0x1007 # Record identifier. length = 0x000C # Number of bytes to follow. # rgb # Line RGB colour. # lns # Line pattern. # we # Line weight. # grbit # Option flags. # index # Index to colour of line. header = [record, length].pack('vv') data = [rgb].pack('V') data += [lns].pack('v') data += [we].pack('v') data += [grbit].pack('v') data += [index].pack('v') append(header, data) end
[ "def", "store_lineformat", "(", "rgb", ",", "lns", ",", "we", ",", "grbit", ",", "index", ")", "record", "=", "0x1007", "length", "=", "0x000C", "header", "=", "[", "record", ",", "length", "]", ".", "pack", "(", "'vv'", ")", "data", "=", "[", "rgb", "]", ".", "pack", "(", "'V'", ")", "data", "+=", "[", "lns", "]", ".", "pack", "(", "'v'", ")", "data", "+=", "[", "we", "]", ".", "pack", "(", "'v'", ")", "data", "+=", "[", "grbit", "]", ".", "pack", "(", "'v'", ")", "data", "+=", "[", "index", "]", ".", "pack", "(", "'v'", ")", "append", "(", "header", ",", "data", ")", "end" ]
Write the LINEFORMAT chart BIFF record.
[ "Write", "the", "LINEFORMAT", "chart", "BIFF", "record", "." ]
d0345067c21b14a7141ba66b6752be8f4be379de
https://github.com/cxn03651/writeexcel/blob/d0345067c21b14a7141ba66b6752be8f4be379de/lib/writeexcel/chart.rb#L1552-L1569
train
cxn03651/writeexcel
lib/writeexcel/chart.rb
Writeexcel.Chart.store_markerformat
def store_markerformat(rgbFore, rgbBack, marker, grbit, icvFore, icvBack, miSize)# :nodoc: record = 0x1009 # Record identifier. length = 0x0014 # Number of bytes to follow. # rgbFore # Foreground RGB color. # rgbBack # Background RGB color. # marker # Type of marker. # grbit # Format flags. # icvFore # Color index marker border. # icvBack # Color index marker fill. # miSize # Size of line markers. header = [record, length].pack('vv') data = [rgbFore].pack('V') data += [rgbBack].pack('V') data += [marker].pack('v') data += [grbit].pack('v') data += [icvFore].pack('v') data += [icvBack].pack('v') data += [miSize].pack('V') append(header, data) end
ruby
def store_markerformat(rgbFore, rgbBack, marker, grbit, icvFore, icvBack, miSize)# :nodoc: record = 0x1009 # Record identifier. length = 0x0014 # Number of bytes to follow. # rgbFore # Foreground RGB color. # rgbBack # Background RGB color. # marker # Type of marker. # grbit # Format flags. # icvFore # Color index marker border. # icvBack # Color index marker fill. # miSize # Size of line markers. header = [record, length].pack('vv') data = [rgbFore].pack('V') data += [rgbBack].pack('V') data += [marker].pack('v') data += [grbit].pack('v') data += [icvFore].pack('v') data += [icvBack].pack('v') data += [miSize].pack('V') append(header, data) end
[ "def", "store_markerformat", "(", "rgbFore", ",", "rgbBack", ",", "marker", ",", "grbit", ",", "icvFore", ",", "icvBack", ",", "miSize", ")", "record", "=", "0x1009", "length", "=", "0x0014", "header", "=", "[", "record", ",", "length", "]", ".", "pack", "(", "'vv'", ")", "data", "=", "[", "rgbFore", "]", ".", "pack", "(", "'V'", ")", "data", "+=", "[", "rgbBack", "]", ".", "pack", "(", "'V'", ")", "data", "+=", "[", "marker", "]", ".", "pack", "(", "'v'", ")", "data", "+=", "[", "grbit", "]", ".", "pack", "(", "'v'", ")", "data", "+=", "[", "icvFore", "]", ".", "pack", "(", "'v'", ")", "data", "+=", "[", "icvBack", "]", ".", "pack", "(", "'v'", ")", "data", "+=", "[", "miSize", "]", ".", "pack", "(", "'V'", ")", "append", "(", "header", ",", "data", ")", "end" ]
Write the MARKERFORMAT chart BIFF record.
[ "Write", "the", "MARKERFORMAT", "chart", "BIFF", "record", "." ]
d0345067c21b14a7141ba66b6752be8f4be379de
https://github.com/cxn03651/writeexcel/blob/d0345067c21b14a7141ba66b6752be8f4be379de/lib/writeexcel/chart.rb#L1574-L1595
train
cxn03651/writeexcel
lib/writeexcel/chart.rb
Writeexcel.Chart.store_objectlink
def store_objectlink(link_type) # :nodoc: record = 0x1027 # Record identifier. length = 0x0006 # Number of bytes to follow. # link_type # Object text link type. link_index1 = 0x0000 # Link index 1. link_index2 = 0x0000 # Link index 2. store_simple(record, length, link_type, link_index1, link_index2) end
ruby
def store_objectlink(link_type) # :nodoc: record = 0x1027 # Record identifier. length = 0x0006 # Number of bytes to follow. # link_type # Object text link type. link_index1 = 0x0000 # Link index 1. link_index2 = 0x0000 # Link index 2. store_simple(record, length, link_type, link_index1, link_index2) end
[ "def", "store_objectlink", "(", "link_type", ")", "record", "=", "0x1027", "length", "=", "0x0006", "link_index1", "=", "0x0000", "link_index2", "=", "0x0000", "store_simple", "(", "record", ",", "length", ",", "link_type", ",", "link_index1", ",", "link_index2", ")", "end" ]
Write the OBJECTLINK chart BIFF record.
[ "Write", "the", "OBJECTLINK", "chart", "BIFF", "record", "." ]
d0345067c21b14a7141ba66b6752be8f4be379de
https://github.com/cxn03651/writeexcel/blob/d0345067c21b14a7141ba66b6752be8f4be379de/lib/writeexcel/chart.rb#L1600-L1608
train
cxn03651/writeexcel
lib/writeexcel/chart.rb
Writeexcel.Chart.store_plotgrowth
def store_plotgrowth # :nodoc: record = 0x1064 # Record identifier. length = 0x0008 # Number of bytes to follow. dx_plot = 0x00010000 # Horz growth for font scale. dy_plot = 0x00010000 # Vert growth for font scale. header = [record, length].pack('vv') data = [dx_plot].pack('V') data += [dy_plot].pack('V') append(header, data) end
ruby
def store_plotgrowth # :nodoc: record = 0x1064 # Record identifier. length = 0x0008 # Number of bytes to follow. dx_plot = 0x00010000 # Horz growth for font scale. dy_plot = 0x00010000 # Vert growth for font scale. header = [record, length].pack('vv') data = [dx_plot].pack('V') data += [dy_plot].pack('V') append(header, data) end
[ "def", "store_plotgrowth", "record", "=", "0x1064", "length", "=", "0x0008", "dx_plot", "=", "0x00010000", "dy_plot", "=", "0x00010000", "header", "=", "[", "record", ",", "length", "]", ".", "pack", "(", "'vv'", ")", "data", "=", "[", "dx_plot", "]", ".", "pack", "(", "'V'", ")", "data", "+=", "[", "dy_plot", "]", ".", "pack", "(", "'V'", ")", "append", "(", "header", ",", "data", ")", "end" ]
Write the PLOTGROWTH chart BIFF record.
[ "Write", "the", "PLOTGROWTH", "chart", "BIFF", "record", "." ]
d0345067c21b14a7141ba66b6752be8f4be379de
https://github.com/cxn03651/writeexcel/blob/d0345067c21b14a7141ba66b6752be8f4be379de/lib/writeexcel/chart.rb#L1635-L1646
train
cxn03651/writeexcel
lib/writeexcel/chart.rb
Writeexcel.Chart.store_pos
def store_pos(mdTopLt, mdBotRt, x1, y1, x2, y2) # :nodoc: record = 0x104F # Record identifier. length = 0x0014 # Number of bytes to follow. # mdTopLt # Top left. # mdBotRt # Bottom right. # x1 # X coordinate. # y1 # Y coordinate. # x2 # Width. # y2 # Height. header = [record, length].pack('vv') data = [mdTopLt].pack('v') data += [mdBotRt].pack('v') data += [x1].pack('V') data += [y1].pack('V') data += [x2].pack('V') data += [y2].pack('V') append(header, data) end
ruby
def store_pos(mdTopLt, mdBotRt, x1, y1, x2, y2) # :nodoc: record = 0x104F # Record identifier. length = 0x0014 # Number of bytes to follow. # mdTopLt # Top left. # mdBotRt # Bottom right. # x1 # X coordinate. # y1 # Y coordinate. # x2 # Width. # y2 # Height. header = [record, length].pack('vv') data = [mdTopLt].pack('v') data += [mdBotRt].pack('v') data += [x1].pack('V') data += [y1].pack('V') data += [x2].pack('V') data += [y2].pack('V') append(header, data) end
[ "def", "store_pos", "(", "mdTopLt", ",", "mdBotRt", ",", "x1", ",", "y1", ",", "x2", ",", "y2", ")", "record", "=", "0x104F", "length", "=", "0x0014", "header", "=", "[", "record", ",", "length", "]", ".", "pack", "(", "'vv'", ")", "data", "=", "[", "mdTopLt", "]", ".", "pack", "(", "'v'", ")", "data", "+=", "[", "mdBotRt", "]", ".", "pack", "(", "'v'", ")", "data", "+=", "[", "x1", "]", ".", "pack", "(", "'V'", ")", "data", "+=", "[", "y1", "]", ".", "pack", "(", "'V'", ")", "data", "+=", "[", "x2", "]", ".", "pack", "(", "'V'", ")", "data", "+=", "[", "y2", "]", ".", "pack", "(", "'V'", ")", "append", "(", "header", ",", "data", ")", "end" ]
Write the POS chart BIFF record. Generally not required when using automatic positioning.
[ "Write", "the", "POS", "chart", "BIFF", "record", ".", "Generally", "not", "required", "when", "using", "automatic", "positioning", "." ]
d0345067c21b14a7141ba66b6752be8f4be379de
https://github.com/cxn03651/writeexcel/blob/d0345067c21b14a7141ba66b6752be8f4be379de/lib/writeexcel/chart.rb#L1652-L1671
train
cxn03651/writeexcel
lib/writeexcel/chart.rb
Writeexcel.Chart.store_serauxtrend
def store_serauxtrend(reg_type, poly_order, equation, r_squared) # :nodoc: record = 0x104B # Record identifier. length = 0x001C # Number of bytes to follow. # reg_type # Regression type. # poly_order # Polynomial order. # equation # Display equation. # r_squared # Display R-squared. # intercept # Forced intercept. # forecast # Forecast forward. # backcast # Forecast backward. # TODO. When supported, intercept needs to be NAN if not used. # Also need to reverse doubles. intercept = ['FFFFFFFF0001FFFF'].pack('H*') forecast = ['0000000000000000'].pack('H*') backcast = ['0000000000000000'].pack('H*') header = [record, length].pack('vv') data = [reg_type].pack('C') data += [poly_order].pack('C') data += intercept data += [equation].pack('C') data += [r_squared].pack('C') data += forecast data += backcast append(header, data) end
ruby
def store_serauxtrend(reg_type, poly_order, equation, r_squared) # :nodoc: record = 0x104B # Record identifier. length = 0x001C # Number of bytes to follow. # reg_type # Regression type. # poly_order # Polynomial order. # equation # Display equation. # r_squared # Display R-squared. # intercept # Forced intercept. # forecast # Forecast forward. # backcast # Forecast backward. # TODO. When supported, intercept needs to be NAN if not used. # Also need to reverse doubles. intercept = ['FFFFFFFF0001FFFF'].pack('H*') forecast = ['0000000000000000'].pack('H*') backcast = ['0000000000000000'].pack('H*') header = [record, length].pack('vv') data = [reg_type].pack('C') data += [poly_order].pack('C') data += intercept data += [equation].pack('C') data += [r_squared].pack('C') data += forecast data += backcast append(header, data) end
[ "def", "store_serauxtrend", "(", "reg_type", ",", "poly_order", ",", "equation", ",", "r_squared", ")", "record", "=", "0x104B", "length", "=", "0x001C", "intercept", "=", "[", "'FFFFFFFF0001FFFF'", "]", ".", "pack", "(", "'H*'", ")", "forecast", "=", "[", "'0000000000000000'", "]", ".", "pack", "(", "'H*'", ")", "backcast", "=", "[", "'0000000000000000'", "]", ".", "pack", "(", "'H*'", ")", "header", "=", "[", "record", ",", "length", "]", ".", "pack", "(", "'vv'", ")", "data", "=", "[", "reg_type", "]", ".", "pack", "(", "'C'", ")", "data", "+=", "[", "poly_order", "]", ".", "pack", "(", "'C'", ")", "data", "+=", "intercept", "data", "+=", "[", "equation", "]", ".", "pack", "(", "'C'", ")", "data", "+=", "[", "r_squared", "]", ".", "pack", "(", "'C'", ")", "data", "+=", "forecast", "data", "+=", "backcast", "append", "(", "header", ",", "data", ")", "end" ]
Write the SERAUXTREND chart BIFF record.
[ "Write", "the", "SERAUXTREND", "chart", "BIFF", "record", "." ]
d0345067c21b14a7141ba66b6752be8f4be379de
https://github.com/cxn03651/writeexcel/blob/d0345067c21b14a7141ba66b6752be8f4be379de/lib/writeexcel/chart.rb#L1676-L1703
train
cxn03651/writeexcel
lib/writeexcel/chart.rb
Writeexcel.Chart.store_series
def store_series(category_count, value_count) # :nodoc: record = 0x1003 # Record identifier. length = 0x000C # Number of bytes to follow. category_type = 0x0001 # Type: category. value_type = 0x0001 # Type: value. # category_count # Num of categories. # value_count # Num of values. bubble_type = 0x0001 # Type: bubble. bubble_count = 0x0000 # Num of bubble values. store_simple(record, length, category_type, value_type, category_count, value_count, bubble_type, bubble_count) end
ruby
def store_series(category_count, value_count) # :nodoc: record = 0x1003 # Record identifier. length = 0x000C # Number of bytes to follow. category_type = 0x0001 # Type: category. value_type = 0x0001 # Type: value. # category_count # Num of categories. # value_count # Num of values. bubble_type = 0x0001 # Type: bubble. bubble_count = 0x0000 # Num of bubble values. store_simple(record, length, category_type, value_type, category_count, value_count, bubble_type, bubble_count) end
[ "def", "store_series", "(", "category_count", ",", "value_count", ")", "record", "=", "0x1003", "length", "=", "0x000C", "category_type", "=", "0x0001", "value_type", "=", "0x0001", "bubble_type", "=", "0x0001", "bubble_count", "=", "0x0000", "store_simple", "(", "record", ",", "length", ",", "category_type", ",", "value_type", ",", "category_count", ",", "value_count", ",", "bubble_type", ",", "bubble_count", ")", "end" ]
Write the SERIES chart BIFF record.
[ "Write", "the", "SERIES", "chart", "BIFF", "record", "." ]
d0345067c21b14a7141ba66b6752be8f4be379de
https://github.com/cxn03651/writeexcel/blob/d0345067c21b14a7141ba66b6752be8f4be379de/lib/writeexcel/chart.rb#L1708-L1720
train
cxn03651/writeexcel
lib/writeexcel/chart.rb
Writeexcel.Chart.store_seriestext
def store_seriestext(str, encoding) # :nodoc: ruby_19 { str = convert_to_ascii_if_ascii(str) } record = 0x100D # Record identifier. length = 0x0000 # Number of bytes to follow. id = 0x0000 # Text id. # str # Text. # encoding # String encoding. cch = str.bytesize # String length. encoding ||= 0 # Character length is num of chars not num of bytes cch /= 2 if encoding != 0 # Change the UTF-16 name from BE to LE str = str.unpack('v*').pack('n*') if encoding != 0 length = 4 + str.bytesize header = [record, length].pack('vv') data = [id].pack('v') data += [cch].pack('C') data += [encoding].pack('C') append(header, data, str) end
ruby
def store_seriestext(str, encoding) # :nodoc: ruby_19 { str = convert_to_ascii_if_ascii(str) } record = 0x100D # Record identifier. length = 0x0000 # Number of bytes to follow. id = 0x0000 # Text id. # str # Text. # encoding # String encoding. cch = str.bytesize # String length. encoding ||= 0 # Character length is num of chars not num of bytes cch /= 2 if encoding != 0 # Change the UTF-16 name from BE to LE str = str.unpack('v*').pack('n*') if encoding != 0 length = 4 + str.bytesize header = [record, length].pack('vv') data = [id].pack('v') data += [cch].pack('C') data += [encoding].pack('C') append(header, data, str) end
[ "def", "store_seriestext", "(", "str", ",", "encoding", ")", "ruby_19", "{", "str", "=", "convert_to_ascii_if_ascii", "(", "str", ")", "}", "record", "=", "0x100D", "length", "=", "0x0000", "id", "=", "0x0000", "cch", "=", "str", ".", "bytesize", "encoding", "||=", "0", "cch", "/=", "2", "if", "encoding", "!=", "0", "str", "=", "str", ".", "unpack", "(", "'v*'", ")", ".", "pack", "(", "'n*'", ")", "if", "encoding", "!=", "0", "length", "=", "4", "+", "str", ".", "bytesize", "header", "=", "[", "record", ",", "length", "]", ".", "pack", "(", "'vv'", ")", "data", "=", "[", "id", "]", ".", "pack", "(", "'v'", ")", "data", "+=", "[", "cch", "]", ".", "pack", "(", "'C'", ")", "data", "+=", "[", "encoding", "]", ".", "pack", "(", "'C'", ")", "append", "(", "header", ",", "data", ",", "str", ")", "end" ]
Write the SERIESTEXT chart BIFF record.
[ "Write", "the", "SERIESTEXT", "chart", "BIFF", "record", "." ]
d0345067c21b14a7141ba66b6752be8f4be379de
https://github.com/cxn03651/writeexcel/blob/d0345067c21b14a7141ba66b6752be8f4be379de/lib/writeexcel/chart.rb#L1725-L1751
train
cxn03651/writeexcel
lib/writeexcel/chart.rb
Writeexcel.Chart.store_shtprops
def store_shtprops # :nodoc: record = 0x1044 # Record identifier. length = 0x0004 # Number of bytes to follow. grbit = 0x000E # Option flags. empty_cells = 0x0000 # Empty cell handling. grbit = 0x000A if @embedded store_simple(record, length, grbit, empty_cells) end
ruby
def store_shtprops # :nodoc: record = 0x1044 # Record identifier. length = 0x0004 # Number of bytes to follow. grbit = 0x000E # Option flags. empty_cells = 0x0000 # Empty cell handling. grbit = 0x000A if @embedded store_simple(record, length, grbit, empty_cells) end
[ "def", "store_shtprops", "record", "=", "0x1044", "length", "=", "0x0004", "grbit", "=", "0x000E", "empty_cells", "=", "0x0000", "grbit", "=", "0x000A", "if", "@embedded", "store_simple", "(", "record", ",", "length", ",", "grbit", ",", "empty_cells", ")", "end" ]
Write the SHTPROPS chart BIFF record.
[ "Write", "the", "SHTPROPS", "chart", "BIFF", "record", "." ]
d0345067c21b14a7141ba66b6752be8f4be379de
https://github.com/cxn03651/writeexcel/blob/d0345067c21b14a7141ba66b6752be8f4be379de/lib/writeexcel/chart.rb#L1778-L1787
train
cxn03651/writeexcel
lib/writeexcel/chart.rb
Writeexcel.Chart.store_tick
def store_tick # :nodoc: record = 0x101E # Record identifier. length = 0x001E # Number of bytes to follow. tktMajor = 0x02 # Type of major tick mark. tktMinor = 0x00 # Type of minor tick mark. tlt = 0x03 # Tick label position. wBkgMode = 0x01 # Background mode. rgb = 0x00000000 # Tick-label RGB colour. reserved1 = 0x00000000 # Reserved. reserved2 = 0x00000000 # Reserved. reserved3 = 0x00000000 # Reserved. reserved4 = 0x00000000 # Reserved. grbit = 0x0023 # Option flags. index = 0x004D # Colour index. reserved5 = 0x0000 # Reserved. header = [record, length].pack('vv') data = [tktMajor].pack('C') data += [tktMinor].pack('C') data += [tlt].pack('C') data += [wBkgMode].pack('C') data += [rgb].pack('V') data += [reserved1].pack('V') data += [reserved2].pack('V') data += [reserved3].pack('V') data += [reserved4].pack('V') data += [grbit].pack('v') data += [index].pack('v') data += [reserved5].pack('v') append(header, data) end
ruby
def store_tick # :nodoc: record = 0x101E # Record identifier. length = 0x001E # Number of bytes to follow. tktMajor = 0x02 # Type of major tick mark. tktMinor = 0x00 # Type of minor tick mark. tlt = 0x03 # Tick label position. wBkgMode = 0x01 # Background mode. rgb = 0x00000000 # Tick-label RGB colour. reserved1 = 0x00000000 # Reserved. reserved2 = 0x00000000 # Reserved. reserved3 = 0x00000000 # Reserved. reserved4 = 0x00000000 # Reserved. grbit = 0x0023 # Option flags. index = 0x004D # Colour index. reserved5 = 0x0000 # Reserved. header = [record, length].pack('vv') data = [tktMajor].pack('C') data += [tktMinor].pack('C') data += [tlt].pack('C') data += [wBkgMode].pack('C') data += [rgb].pack('V') data += [reserved1].pack('V') data += [reserved2].pack('V') data += [reserved3].pack('V') data += [reserved4].pack('V') data += [grbit].pack('v') data += [index].pack('v') data += [reserved5].pack('v') append(header, data) end
[ "def", "store_tick", "record", "=", "0x101E", "length", "=", "0x001E", "tktMajor", "=", "0x02", "tktMinor", "=", "0x00", "tlt", "=", "0x03", "wBkgMode", "=", "0x01", "rgb", "=", "0x00000000", "reserved1", "=", "0x00000000", "reserved2", "=", "0x00000000", "reserved3", "=", "0x00000000", "reserved4", "=", "0x00000000", "grbit", "=", "0x0023", "index", "=", "0x004D", "reserved5", "=", "0x0000", "header", "=", "[", "record", ",", "length", "]", ".", "pack", "(", "'vv'", ")", "data", "=", "[", "tktMajor", "]", ".", "pack", "(", "'C'", ")", "data", "+=", "[", "tktMinor", "]", ".", "pack", "(", "'C'", ")", "data", "+=", "[", "tlt", "]", ".", "pack", "(", "'C'", ")", "data", "+=", "[", "wBkgMode", "]", ".", "pack", "(", "'C'", ")", "data", "+=", "[", "rgb", "]", ".", "pack", "(", "'V'", ")", "data", "+=", "[", "reserved1", "]", ".", "pack", "(", "'V'", ")", "data", "+=", "[", "reserved2", "]", ".", "pack", "(", "'V'", ")", "data", "+=", "[", "reserved3", "]", ".", "pack", "(", "'V'", ")", "data", "+=", "[", "reserved4", "]", ".", "pack", "(", "'V'", ")", "data", "+=", "[", "grbit", "]", ".", "pack", "(", "'v'", ")", "data", "+=", "[", "index", "]", ".", "pack", "(", "'v'", ")", "data", "+=", "[", "reserved5", "]", ".", "pack", "(", "'v'", ")", "append", "(", "header", ",", "data", ")", "end" ]
Write the TICK chart BIFF record.
[ "Write", "the", "TICK", "chart", "BIFF", "record", "." ]
d0345067c21b14a7141ba66b6752be8f4be379de
https://github.com/cxn03651/writeexcel/blob/d0345067c21b14a7141ba66b6752be8f4be379de/lib/writeexcel/chart.rb#L1828-L1859
train
cxn03651/writeexcel
lib/writeexcel/chart.rb
Writeexcel.Chart.store_valuerange
def store_valuerange # :nodoc: record = 0x101F # Record identifier. length = 0x002A # Number of bytes to follow. numMin = 0x00000000 # Minimum value on axis. numMax = 0x00000000 # Maximum value on axis. numMajor = 0x00000000 # Value of major increment. numMinor = 0x00000000 # Value of minor increment. numCross = 0x00000000 # Value where category axis crosses. grbit = 0x011F # Format flags. # TODO. Reverse doubles when they are handled. header = [record, length].pack('vv') data = [numMin].pack('d') data += [numMax].pack('d') data += [numMajor].pack('d') data += [numMinor].pack('d') data += [numCross].pack('d') data += [grbit].pack('v') append(header, data) end
ruby
def store_valuerange # :nodoc: record = 0x101F # Record identifier. length = 0x002A # Number of bytes to follow. numMin = 0x00000000 # Minimum value on axis. numMax = 0x00000000 # Maximum value on axis. numMajor = 0x00000000 # Value of major increment. numMinor = 0x00000000 # Value of minor increment. numCross = 0x00000000 # Value where category axis crosses. grbit = 0x011F # Format flags. # TODO. Reverse doubles when they are handled. header = [record, length].pack('vv') data = [numMin].pack('d') data += [numMax].pack('d') data += [numMajor].pack('d') data += [numMinor].pack('d') data += [numCross].pack('d') data += [grbit].pack('v') append(header, data) end
[ "def", "store_valuerange", "record", "=", "0x101F", "length", "=", "0x002A", "numMin", "=", "0x00000000", "numMax", "=", "0x00000000", "numMajor", "=", "0x00000000", "numMinor", "=", "0x00000000", "numCross", "=", "0x00000000", "grbit", "=", "0x011F", "header", "=", "[", "record", ",", "length", "]", ".", "pack", "(", "'vv'", ")", "data", "=", "[", "numMin", "]", ".", "pack", "(", "'d'", ")", "data", "+=", "[", "numMax", "]", ".", "pack", "(", "'d'", ")", "data", "+=", "[", "numMajor", "]", ".", "pack", "(", "'d'", ")", "data", "+=", "[", "numMinor", "]", ".", "pack", "(", "'d'", ")", "data", "+=", "[", "numCross", "]", ".", "pack", "(", "'d'", ")", "data", "+=", "[", "grbit", "]", ".", "pack", "(", "'v'", ")", "append", "(", "header", ",", "data", ")", "end" ]
Write the VALUERANGE chart BIFF record.
[ "Write", "the", "VALUERANGE", "chart", "BIFF", "record", "." ]
d0345067c21b14a7141ba66b6752be8f4be379de
https://github.com/cxn03651/writeexcel/blob/d0345067c21b14a7141ba66b6752be8f4be379de/lib/writeexcel/chart.rb#L1864-L1885
train
cxn03651/writeexcel
lib/writeexcel/formula.rb
Writeexcel.Formula.parse_formula
def parse_formula(formula, byte_stream = false) # Build the parse tree for the formula tokens = reverse(parse(formula)) # Add a volatile token if the formula contains a volatile function. # This must be the first token in the list # tokens.unshift('_vol') if check_volatile(tokens) != 0 # The return value depends on which Worksheet.pm method is the caller unless byte_stream # Parse formula to see if it throws any errors and then # return raw tokens to Worksheet::store_formula() # parse_tokens(tokens) tokens else # Return byte stream to Worksheet::write_formula() parse_tokens(tokens) end end
ruby
def parse_formula(formula, byte_stream = false) # Build the parse tree for the formula tokens = reverse(parse(formula)) # Add a volatile token if the formula contains a volatile function. # This must be the first token in the list # tokens.unshift('_vol') if check_volatile(tokens) != 0 # The return value depends on which Worksheet.pm method is the caller unless byte_stream # Parse formula to see if it throws any errors and then # return raw tokens to Worksheet::store_formula() # parse_tokens(tokens) tokens else # Return byte stream to Worksheet::write_formula() parse_tokens(tokens) end end
[ "def", "parse_formula", "(", "formula", ",", "byte_stream", "=", "false", ")", "tokens", "=", "reverse", "(", "parse", "(", "formula", ")", ")", "tokens", ".", "unshift", "(", "'_vol'", ")", "if", "check_volatile", "(", "tokens", ")", "!=", "0", "unless", "byte_stream", "parse_tokens", "(", "tokens", ")", "tokens", "else", "parse_tokens", "(", "tokens", ")", "end", "end" ]
Takes a textual description of a formula and returns a RPN encoded byte string.
[ "Takes", "a", "textual", "description", "of", "a", "formula", "and", "returns", "a", "RPN", "encoded", "byte", "string", "." ]
d0345067c21b14a7141ba66b6752be8f4be379de
https://github.com/cxn03651/writeexcel/blob/d0345067c21b14a7141ba66b6752be8f4be379de/lib/writeexcel/formula.rb#L38-L58
train
cxn03651/writeexcel
lib/writeexcel/formula.rb
Writeexcel.Formula.parse_tokens
def parse_tokens(tokens) parse_str = '' last_type = '' modifier = '' num_args = 0 _class = 0 _classary = [1] args = tokens.dup # A note about the class modifiers used below. In general the class, # "reference" or "value", of a function is applied to all of its operands. # However, in certain circumstances the operands can have mixed classes, # e.g. =VLOOKUP with external references. These will eventually be dealt # with by the parser. However, as a workaround the class type of a token # can be changed via the repeat_formula interface. Thus, a _ref2d token can # be changed by the user to _ref2dA or _ref2dR to change its token class. # while (!args.empty?) token = args.shift if (token == '_arg') num_args = args.shift elsif (token == '_class') token = args.shift _class = @functions[token][2] # If _class is undef then it means that the function isn't valid. exit "Unknown function #{token}() in formula\n" if _class.nil? _classary.push(_class) elsif (token == '_vol') parse_str += convert_volatile() elsif (token == 'ptgBool') token = args.shift parse_str += convert_bool(token) elsif (token == '_num') token = args.shift parse_str += convert_number(token) elsif (token == '_str') token = args.shift parse_str += convert_string(token) elsif (token =~ /^_ref2d/) modifier = token.sub(/_ref2d/, '') _class = _classary[-1] _class = 0 if modifier == 'R' _class = 1 if modifier == 'V' token = args.shift parse_str += convert_ref2d(token, _class) elsif (token =~ /^_ref3d/) modifier = token.sub(/_ref3d/,'') _class = _classary[-1] _class = 0 if modifier == 'R' _class = 1 if modifier == 'V' token = args.shift parse_str += convert_ref3d(token, _class) elsif (token =~ /^_range2d/) modifier = token.sub(/_range2d/,'') _class = _classary[-1] _class = 0 if modifier == 'R' _class = 1 if modifier == 'V' token = args.shift parse_str += convert_range2d(token, _class) elsif (token =~ /^_range3d/) modifier = token.sub(/_range3d/,'') _class = _classary[-1] _class = 0 if modifier == 'R' _class = 1 if modifier == 'V' token = args.shift parse_str += convert_range3d(token, _class) elsif (token =~ /^_name/) modifier = token.sub(/_name/, '') _class = _classary[-1] _class = 0 if modifier == 'R' _class = 1 if modifier == 'V' token = args.shift parse_str += convert_name(token, _class) elsif (token == '_func') token = args.shift parse_str += convert_function(token, num_args.to_i) _classary.pop num_args = 0 # Reset after use elsif @ptg[token] parse_str += [@ptg[token]].pack("C") else # Unrecognised token return nil end end parse_str end
ruby
def parse_tokens(tokens) parse_str = '' last_type = '' modifier = '' num_args = 0 _class = 0 _classary = [1] args = tokens.dup # A note about the class modifiers used below. In general the class, # "reference" or "value", of a function is applied to all of its operands. # However, in certain circumstances the operands can have mixed classes, # e.g. =VLOOKUP with external references. These will eventually be dealt # with by the parser. However, as a workaround the class type of a token # can be changed via the repeat_formula interface. Thus, a _ref2d token can # be changed by the user to _ref2dA or _ref2dR to change its token class. # while (!args.empty?) token = args.shift if (token == '_arg') num_args = args.shift elsif (token == '_class') token = args.shift _class = @functions[token][2] # If _class is undef then it means that the function isn't valid. exit "Unknown function #{token}() in formula\n" if _class.nil? _classary.push(_class) elsif (token == '_vol') parse_str += convert_volatile() elsif (token == 'ptgBool') token = args.shift parse_str += convert_bool(token) elsif (token == '_num') token = args.shift parse_str += convert_number(token) elsif (token == '_str') token = args.shift parse_str += convert_string(token) elsif (token =~ /^_ref2d/) modifier = token.sub(/_ref2d/, '') _class = _classary[-1] _class = 0 if modifier == 'R' _class = 1 if modifier == 'V' token = args.shift parse_str += convert_ref2d(token, _class) elsif (token =~ /^_ref3d/) modifier = token.sub(/_ref3d/,'') _class = _classary[-1] _class = 0 if modifier == 'R' _class = 1 if modifier == 'V' token = args.shift parse_str += convert_ref3d(token, _class) elsif (token =~ /^_range2d/) modifier = token.sub(/_range2d/,'') _class = _classary[-1] _class = 0 if modifier == 'R' _class = 1 if modifier == 'V' token = args.shift parse_str += convert_range2d(token, _class) elsif (token =~ /^_range3d/) modifier = token.sub(/_range3d/,'') _class = _classary[-1] _class = 0 if modifier == 'R' _class = 1 if modifier == 'V' token = args.shift parse_str += convert_range3d(token, _class) elsif (token =~ /^_name/) modifier = token.sub(/_name/, '') _class = _classary[-1] _class = 0 if modifier == 'R' _class = 1 if modifier == 'V' token = args.shift parse_str += convert_name(token, _class) elsif (token == '_func') token = args.shift parse_str += convert_function(token, num_args.to_i) _classary.pop num_args = 0 # Reset after use elsif @ptg[token] parse_str += [@ptg[token]].pack("C") else # Unrecognised token return nil end end parse_str end
[ "def", "parse_tokens", "(", "tokens", ")", "parse_str", "=", "''", "last_type", "=", "''", "modifier", "=", "''", "num_args", "=", "0", "_class", "=", "0", "_classary", "=", "[", "1", "]", "args", "=", "tokens", ".", "dup", "while", "(", "!", "args", ".", "empty?", ")", "token", "=", "args", ".", "shift", "if", "(", "token", "==", "'_arg'", ")", "num_args", "=", "args", ".", "shift", "elsif", "(", "token", "==", "'_class'", ")", "token", "=", "args", ".", "shift", "_class", "=", "@functions", "[", "token", "]", "[", "2", "]", "exit", "\"Unknown function #{token}() in formula\\n\"", "if", "_class", ".", "nil?", "_classary", ".", "push", "(", "_class", ")", "elsif", "(", "token", "==", "'_vol'", ")", "parse_str", "+=", "convert_volatile", "(", ")", "elsif", "(", "token", "==", "'ptgBool'", ")", "token", "=", "args", ".", "shift", "parse_str", "+=", "convert_bool", "(", "token", ")", "elsif", "(", "token", "==", "'_num'", ")", "token", "=", "args", ".", "shift", "parse_str", "+=", "convert_number", "(", "token", ")", "elsif", "(", "token", "==", "'_str'", ")", "token", "=", "args", ".", "shift", "parse_str", "+=", "convert_string", "(", "token", ")", "elsif", "(", "token", "=~", "/", "/", ")", "modifier", "=", "token", ".", "sub", "(", "/", "/", ",", "''", ")", "_class", "=", "_classary", "[", "-", "1", "]", "_class", "=", "0", "if", "modifier", "==", "'R'", "_class", "=", "1", "if", "modifier", "==", "'V'", "token", "=", "args", ".", "shift", "parse_str", "+=", "convert_ref2d", "(", "token", ",", "_class", ")", "elsif", "(", "token", "=~", "/", "/", ")", "modifier", "=", "token", ".", "sub", "(", "/", "/", ",", "''", ")", "_class", "=", "_classary", "[", "-", "1", "]", "_class", "=", "0", "if", "modifier", "==", "'R'", "_class", "=", "1", "if", "modifier", "==", "'V'", "token", "=", "args", ".", "shift", "parse_str", "+=", "convert_ref3d", "(", "token", ",", "_class", ")", "elsif", "(", "token", "=~", "/", "/", ")", "modifier", "=", "token", ".", "sub", "(", "/", "/", ",", "''", ")", "_class", "=", "_classary", "[", "-", "1", "]", "_class", "=", "0", "if", "modifier", "==", "'R'", "_class", "=", "1", "if", "modifier", "==", "'V'", "token", "=", "args", ".", "shift", "parse_str", "+=", "convert_range2d", "(", "token", ",", "_class", ")", "elsif", "(", "token", "=~", "/", "/", ")", "modifier", "=", "token", ".", "sub", "(", "/", "/", ",", "''", ")", "_class", "=", "_classary", "[", "-", "1", "]", "_class", "=", "0", "if", "modifier", "==", "'R'", "_class", "=", "1", "if", "modifier", "==", "'V'", "token", "=", "args", ".", "shift", "parse_str", "+=", "convert_range3d", "(", "token", ",", "_class", ")", "elsif", "(", "token", "=~", "/", "/", ")", "modifier", "=", "token", ".", "sub", "(", "/", "/", ",", "''", ")", "_class", "=", "_classary", "[", "-", "1", "]", "_class", "=", "0", "if", "modifier", "==", "'R'", "_class", "=", "1", "if", "modifier", "==", "'V'", "token", "=", "args", ".", "shift", "parse_str", "+=", "convert_name", "(", "token", ",", "_class", ")", "elsif", "(", "token", "==", "'_func'", ")", "token", "=", "args", ".", "shift", "parse_str", "+=", "convert_function", "(", "token", ",", "num_args", ".", "to_i", ")", "_classary", ".", "pop", "num_args", "=", "0", "elsif", "@ptg", "[", "token", "]", "parse_str", "+=", "[", "@ptg", "[", "token", "]", "]", ".", "pack", "(", "\"C\"", ")", "else", "return", "nil", "end", "end", "parse_str", "end" ]
Convert each token or token pair to its Excel 'ptg' equivalent.
[ "Convert", "each", "token", "or", "token", "pair", "to", "its", "Excel", "ptg", "equivalent", "." ]
d0345067c21b14a7141ba66b6752be8f4be379de
https://github.com/cxn03651/writeexcel/blob/d0345067c21b14a7141ba66b6752be8f4be379de/lib/writeexcel/formula.rb#L63-L150
train
cxn03651/writeexcel
lib/writeexcel/formula.rb
Writeexcel.Formula.convert_number
def convert_number(num) # Integer in the range 0..2**16-1 if ((num =~ /^\d+$/) && (num.to_i <= 65535)) return [@ptg['ptgInt'], num.to_i].pack("Cv") else # A float num = [num.to_f].pack("d") num.reverse! if @byte_order return [@ptg['ptgNum']].pack("C") + num end end
ruby
def convert_number(num) # Integer in the range 0..2**16-1 if ((num =~ /^\d+$/) && (num.to_i <= 65535)) return [@ptg['ptgInt'], num.to_i].pack("Cv") else # A float num = [num.to_f].pack("d") num.reverse! if @byte_order return [@ptg['ptgNum']].pack("C") + num end end
[ "def", "convert_number", "(", "num", ")", "if", "(", "(", "num", "=~", "/", "\\d", "/", ")", "&&", "(", "num", ".", "to_i", "<=", "65535", ")", ")", "return", "[", "@ptg", "[", "'ptgInt'", "]", ",", "num", ".", "to_i", "]", ".", "pack", "(", "\"Cv\"", ")", "else", "num", "=", "[", "num", ".", "to_f", "]", ".", "pack", "(", "\"d\"", ")", "num", ".", "reverse!", "if", "@byte_order", "return", "[", "@ptg", "[", "'ptgNum'", "]", "]", ".", "pack", "(", "\"C\"", ")", "+", "num", "end", "end" ]
Convert a number token to ptgInt or ptgNum
[ "Convert", "a", "number", "token", "to", "ptgInt", "or", "ptgNum" ]
d0345067c21b14a7141ba66b6752be8f4be379de
https://github.com/cxn03651/writeexcel/blob/d0345067c21b14a7141ba66b6752be8f4be379de/lib/writeexcel/formula.rb#L265-L274
train
cxn03651/writeexcel
lib/writeexcel/formula.rb
Writeexcel.Formula.convert_string
def convert_string(str) ruby_19 { str = convert_to_ascii_if_ascii(str) } encoding = 0 str.sub!(/^"/,'') # Remove leading " str.sub!(/"$/,'') # Remove trailing " str.gsub!(/""/,'"') # Substitute Excel's escaped double quote "" for " # number of characters in str length = ruby_18 { str.gsub(/[^\WA-Za-z_\d]/, ' ').length } || ruby_19 { str.length } # Handle utf8 strings if is_utf8?(str) str = utf8_to_16le(str) ruby_19 { str.force_encoding('BINARY') } encoding = 1 end exit "String in formula has more than 255 chars\n" if length > 255 [@ptg['ptgStr'], length, encoding].pack("CCC") + str end
ruby
def convert_string(str) ruby_19 { str = convert_to_ascii_if_ascii(str) } encoding = 0 str.sub!(/^"/,'') # Remove leading " str.sub!(/"$/,'') # Remove trailing " str.gsub!(/""/,'"') # Substitute Excel's escaped double quote "" for " # number of characters in str length = ruby_18 { str.gsub(/[^\WA-Za-z_\d]/, ' ').length } || ruby_19 { str.length } # Handle utf8 strings if is_utf8?(str) str = utf8_to_16le(str) ruby_19 { str.force_encoding('BINARY') } encoding = 1 end exit "String in formula has more than 255 chars\n" if length > 255 [@ptg['ptgStr'], length, encoding].pack("CCC") + str end
[ "def", "convert_string", "(", "str", ")", "ruby_19", "{", "str", "=", "convert_to_ascii_if_ascii", "(", "str", ")", "}", "encoding", "=", "0", "str", ".", "sub!", "(", "/", "/", ",", "''", ")", "str", ".", "sub!", "(", "/", "/", ",", "''", ")", "str", ".", "gsub!", "(", "/", "/", ",", "'\"'", ")", "length", "=", "ruby_18", "{", "str", ".", "gsub", "(", "/", "\\W", "\\d", "/", ",", "' '", ")", ".", "length", "}", "||", "ruby_19", "{", "str", ".", "length", "}", "if", "is_utf8?", "(", "str", ")", "str", "=", "utf8_to_16le", "(", "str", ")", "ruby_19", "{", "str", ".", "force_encoding", "(", "'BINARY'", ")", "}", "encoding", "=", "1", "end", "exit", "\"String in formula has more than 255 chars\\n\"", "if", "length", ">", "255", "[", "@ptg", "[", "'ptgStr'", "]", ",", "length", ",", "encoding", "]", ".", "pack", "(", "\"CCC\"", ")", "+", "str", "end" ]
Convert a string to a ptg Str.
[ "Convert", "a", "string", "to", "a", "ptg", "Str", "." ]
d0345067c21b14a7141ba66b6752be8f4be379de
https://github.com/cxn03651/writeexcel/blob/d0345067c21b14a7141ba66b6752be8f4be379de/lib/writeexcel/formula.rb#L279-L302
train
cxn03651/writeexcel
lib/writeexcel/formula.rb
Writeexcel.Formula.convert_function
def convert_function(token, num_args) exit "Unknown function #{token}() in formula\n" if @functions[token][0].nil? args = @functions[token][1] # Fixed number of args eg. TIME($i,$j,$k). if (args >= 0) # Check that the number of args is valid. if (args != num_args) raise "Incorrect number of arguments for #{token}() in formula\n" else return [@ptg['ptgFuncV'], @functions[token][0]].pack("Cv") end end # Variable number of args eg. SUM(i,j,k, ..). if (args == -1) return [@ptg['ptgFuncVarV'], num_args, @functions[token][0]].pack("CCv") end end
ruby
def convert_function(token, num_args) exit "Unknown function #{token}() in formula\n" if @functions[token][0].nil? args = @functions[token][1] # Fixed number of args eg. TIME($i,$j,$k). if (args >= 0) # Check that the number of args is valid. if (args != num_args) raise "Incorrect number of arguments for #{token}() in formula\n" else return [@ptg['ptgFuncV'], @functions[token][0]].pack("Cv") end end # Variable number of args eg. SUM(i,j,k, ..). if (args == -1) return [@ptg['ptgFuncVarV'], num_args, @functions[token][0]].pack("CCv") end end
[ "def", "convert_function", "(", "token", ",", "num_args", ")", "exit", "\"Unknown function #{token}() in formula\\n\"", "if", "@functions", "[", "token", "]", "[", "0", "]", ".", "nil?", "args", "=", "@functions", "[", "token", "]", "[", "1", "]", "if", "(", "args", ">=", "0", ")", "if", "(", "args", "!=", "num_args", ")", "raise", "\"Incorrect number of arguments for #{token}() in formula\\n\"", "else", "return", "[", "@ptg", "[", "'ptgFuncV'", "]", ",", "@functions", "[", "token", "]", "[", "0", "]", "]", ".", "pack", "(", "\"Cv\"", ")", "end", "end", "if", "(", "args", "==", "-", "1", ")", "return", "[", "@ptg", "[", "'ptgFuncVarV'", "]", ",", "num_args", ",", "@functions", "[", "token", "]", "[", "0", "]", "]", ".", "pack", "(", "\"CCv\"", ")", "end", "end" ]
Convert a function to a ptgFunc or ptgFuncVarV depending on the number of args that it takes.
[ "Convert", "a", "function", "to", "a", "ptgFunc", "or", "ptgFuncVarV", "depending", "on", "the", "number", "of", "args", "that", "it", "takes", "." ]
d0345067c21b14a7141ba66b6752be8f4be379de
https://github.com/cxn03651/writeexcel/blob/d0345067c21b14a7141ba66b6752be8f4be379de/lib/writeexcel/formula.rb#L532-L551
train
cxn03651/writeexcel
lib/writeexcel/formula.rb
Writeexcel.Formula.convert_name
def convert_name(name, _class) name_index = get_name_index(name) # The ptg value depends on the class of the ptg. if _class == 0 ptgName = @ptg['ptgName'] elsif _class == 1 ptgName = @ptg['ptgNameV'] elsif _class == 2 ptgName = @ptg['ptgNameA'] end [ptgName, name_index].pack('CV') end
ruby
def convert_name(name, _class) name_index = get_name_index(name) # The ptg value depends on the class of the ptg. if _class == 0 ptgName = @ptg['ptgName'] elsif _class == 1 ptgName = @ptg['ptgNameV'] elsif _class == 2 ptgName = @ptg['ptgNameA'] end [ptgName, name_index].pack('CV') end
[ "def", "convert_name", "(", "name", ",", "_class", ")", "name_index", "=", "get_name_index", "(", "name", ")", "if", "_class", "==", "0", "ptgName", "=", "@ptg", "[", "'ptgName'", "]", "elsif", "_class", "==", "1", "ptgName", "=", "@ptg", "[", "'ptgNameV'", "]", "elsif", "_class", "==", "2", "ptgName", "=", "@ptg", "[", "'ptgNameA'", "]", "end", "[", "ptgName", ",", "name_index", "]", ".", "pack", "(", "'CV'", ")", "end" ]
Convert a symbolic name into a name reference.
[ "Convert", "a", "symbolic", "name", "into", "a", "name", "reference", "." ]
d0345067c21b14a7141ba66b6752be8f4be379de
https://github.com/cxn03651/writeexcel/blob/d0345067c21b14a7141ba66b6752be8f4be379de/lib/writeexcel/formula.rb#L556-L569
train
cxn03651/writeexcel
lib/writeexcel/worksheet.rb
Writeexcel.Worksheet.close
def close #:nodoc: ################################################ # Prepend in reverse order!! # # Prepend the sheet dimensions store_dimensions # Prepend the autofilter filters. store_autofilters # Prepend the sheet autofilter info. store_autofilterinfo # Prepend the sheet filtermode record. store_filtermode # Prepend the COLINFO records if they exist @colinfo.reverse.each do |colinfo| store_colinfo(colinfo) end # Prepend the DEFCOLWIDTH record store_defcol # Prepend the sheet password store_password # Prepend the sheet protection store_protect store_obj_protect # Prepend the page setup store_setup # Prepend the bottom margin store_margin_bottom # Prepend the top margin store_margin_top # Prepend the right margin store_margin_right # Prepend the left margin store_margin_left # Prepend the page vertical centering store_vcenter # Prepend the page horizontal centering store_hcenter # Prepend the page footer store_footer # Prepend the page header store_header # Prepend the vertical page breaks store_vbreak # Prepend the horizontal page breaks store_hbreak # Prepend WSBOOL store_wsbool # Prepend the default row height. store_defrow # Prepend GUTS store_guts # Prepend GRIDSET store_gridset # Prepend PRINTGRIDLINES store_print_gridlines # Prepend PRINTHEADERS store_print_headers # # End of prepend. Read upwards from here. ################################################ # Append store_table store_images store_charts store_filters store_comments store_window2 store_page_view store_zoom store_panes(*@panes) if @panes && [email protected]? store_selection(*@selection) store_validation_count store_validations store_tab_color store_eof # Prepend the BOF and INDEX records store_index store_bof(0x0010) end
ruby
def close #:nodoc: ################################################ # Prepend in reverse order!! # # Prepend the sheet dimensions store_dimensions # Prepend the autofilter filters. store_autofilters # Prepend the sheet autofilter info. store_autofilterinfo # Prepend the sheet filtermode record. store_filtermode # Prepend the COLINFO records if they exist @colinfo.reverse.each do |colinfo| store_colinfo(colinfo) end # Prepend the DEFCOLWIDTH record store_defcol # Prepend the sheet password store_password # Prepend the sheet protection store_protect store_obj_protect # Prepend the page setup store_setup # Prepend the bottom margin store_margin_bottom # Prepend the top margin store_margin_top # Prepend the right margin store_margin_right # Prepend the left margin store_margin_left # Prepend the page vertical centering store_vcenter # Prepend the page horizontal centering store_hcenter # Prepend the page footer store_footer # Prepend the page header store_header # Prepend the vertical page breaks store_vbreak # Prepend the horizontal page breaks store_hbreak # Prepend WSBOOL store_wsbool # Prepend the default row height. store_defrow # Prepend GUTS store_guts # Prepend GRIDSET store_gridset # Prepend PRINTGRIDLINES store_print_gridlines # Prepend PRINTHEADERS store_print_headers # # End of prepend. Read upwards from here. ################################################ # Append store_table store_images store_charts store_filters store_comments store_window2 store_page_view store_zoom store_panes(*@panes) if @panes && [email protected]? store_selection(*@selection) store_validation_count store_validations store_tab_color store_eof # Prepend the BOF and INDEX records store_index store_bof(0x0010) end
[ "def", "close", "store_dimensions", "store_autofilters", "store_autofilterinfo", "store_filtermode", "@colinfo", ".", "reverse", ".", "each", "do", "|", "colinfo", "|", "store_colinfo", "(", "colinfo", ")", "end", "store_defcol", "store_password", "store_protect", "store_obj_protect", "store_setup", "store_margin_bottom", "store_margin_top", "store_margin_right", "store_margin_left", "store_vcenter", "store_hcenter", "store_footer", "store_header", "store_vbreak", "store_hbreak", "store_wsbool", "store_defrow", "store_guts", "store_gridset", "store_print_gridlines", "store_print_headers", "store_table", "store_images", "store_charts", "store_filters", "store_comments", "store_window2", "store_page_view", "store_zoom", "store_panes", "(", "*", "@panes", ")", "if", "@panes", "&&", "!", "@panes", ".", "empty?", "store_selection", "(", "*", "@selection", ")", "store_validation_count", "store_validations", "store_tab_color", "store_eof", "store_index", "store_bof", "(", "0x0010", ")", "end" ]
Constructor. Creates a new Worksheet object from a BIFFwriter object Add data to the beginning of the workbook (note the reverse order) and to the end of the workbook.
[ "Constructor", ".", "Creates", "a", "new", "Worksheet", "object", "from", "a", "BIFFwriter", "object" ]
d0345067c21b14a7141ba66b6752be8f4be379de
https://github.com/cxn03651/writeexcel/blob/d0345067c21b14a7141ba66b6752be8f4be379de/lib/writeexcel/worksheet.rb#L163-L268
train
cxn03651/writeexcel
lib/writeexcel/worksheet.rb
Writeexcel.Worksheet.hide
def hide @hidden = true # A hidden worksheet shouldn't be active or selected. @selected = false @workbook.worksheets.activesheet = @workbook.worksheets.first @workbook.worksheets.firstsheet = @workbook.worksheets.first end
ruby
def hide @hidden = true # A hidden worksheet shouldn't be active or selected. @selected = false @workbook.worksheets.activesheet = @workbook.worksheets.first @workbook.worksheets.firstsheet = @workbook.worksheets.first end
[ "def", "hide", "@hidden", "=", "true", "@selected", "=", "false", "@workbook", ".", "worksheets", ".", "activesheet", "=", "@workbook", ".", "worksheets", ".", "first", "@workbook", ".", "worksheets", ".", "firstsheet", "=", "@workbook", ".", "worksheets", ".", "first", "end" ]
Hide this worksheet. The hide() method is used to hide a worksheet: worksheet2.hide You may wish to hide a worksheet in order to avoid confusing a user with intermediate data or calculations. A hidden worksheet can not be activated or selected so this method is mutually exclusive with the activate() and select() methods. In addition, since the first worksheet will default to being the active worksheet, you cannot hide the first worksheet without activating another sheet: worksheet2.activate worksheet1.hide
[ "Hide", "this", "worksheet", "." ]
d0345067c21b14a7141ba66b6752be8f4be379de
https://github.com/cxn03651/writeexcel/blob/d0345067c21b14a7141ba66b6752be8f4be379de/lib/writeexcel/worksheet.rb#L355-L362
train
cxn03651/writeexcel
lib/writeexcel/worksheet.rb
Writeexcel.Worksheet.set_tab_color
def set_tab_color(color) color = Colors.new.get_color(color) color = 0 if color == 0x7FFF # Default color. @tab_color = color end
ruby
def set_tab_color(color) color = Colors.new.get_color(color) color = 0 if color == 0x7FFF # Default color. @tab_color = color end
[ "def", "set_tab_color", "(", "color", ")", "color", "=", "Colors", ".", "new", ".", "get_color", "(", "color", ")", "color", "=", "0", "if", "color", "==", "0x7FFF", "@tab_color", "=", "color", "end" ]
Set the colour of the worksheet colour. The set_tab_color() method is used to change the colour of the worksheet tab. This feature is only available in Excel 2002 and later. You can use one of the standard colour names provided by the Format object or a colour index. See "COLOURS IN EXCEL" and the set_custom_color() method. worksheet1.set_tab_color('red') worksheet2.set_tab_color(0x0C) See the tab_colors.rb program in the examples directory of the distro.
[ "Set", "the", "colour", "of", "the", "worksheet", "colour", "." ]
d0345067c21b14a7141ba66b6752be8f4be379de
https://github.com/cxn03651/writeexcel/blob/d0345067c21b14a7141ba66b6752be8f4be379de/lib/writeexcel/worksheet.rb#L1065-L1069
train