sixarm_ruby_ramp

SixArm.com » Ruby » Ramp is a toolkit of Ruby base class extensions

https://github.com/sixarm/sixarm_ruby_ramp

Science Score: 44.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (11.0%) to scientific vocabulary

Keywords

gem ruby
Last synced: 4 months ago · JSON representation ·

Repository

SixArm.com » Ruby » Ramp is a toolkit of Ruby base class extensions

Basic Info
  • Host: GitHub
  • Owner: SixArm
  • License: other
  • Language: Ruby
  • Default Branch: main
  • Homepage: http://sixarm.com
  • Size: 1.73 MB
Statistics
  • Stars: 1
  • Watchers: 2
  • Forks: 0
  • Open Issues: 0
  • Releases: 0
Topics
gem ruby
Created over 15 years ago · Last pushed over 2 years ago
Metadata Files
Readme Changelog Contributing License Code of conduct Citation Codeowners

README.md

SixArm.com → Ruby →
Ramp is a toolkit of Ruby extensions

Gem Version Build Status Code Climate

Introduction

Ramp is a library of extensions to Ruby base classes.

We extend Array, Date, Enumerable, Hash, Kernel, Numeric, Object, Process, String, Time, and YAML.

For docs go to http://sixarm.com/sixarm_ruby_ramp/doc

Want to help? We're happy to get pull requests.

Install

Gem

To install this gem in your shell or terminal:

gem install sixarm_ruby_ramp

Gemfile

To add this gem to your Gemfile:

gem 'sixarm_ruby_ramp'

Require

To require the gem in your code:

require 'sixarm_ruby_ramp'

Array

  • car, cdr: aka first, rest (see shifted)
  • choice, choices: one or more random elements from an array
  • cross: return the cross pairings of an array with another array
  • divvy: divides an array, like a pie, into a specified number of slices (deprecated)
  • onto: return a hash that maps an array's keys on to another array's values
  • rotate: moves the first element of an array to the end
  • rest: return the rest of the items of the array (aka cdr, aka shifted)
  • shifted, shifted!: return an array with the first n items shifted (aka cdr, aka rest)
  • shuffle, shuffle!: randomly sort an array efficiently (backport)
  • slices: divide an array into specified number of equal size sub-arrays (deprecated)
  • to_csv: join a 2D array to a string as CSV (Comma Separated Values)
  • to_tdf: join a 2D array to a string as TDF (Tab Delimited Format)
  • to_tsv: join a 2D array to a string as TSV (Tab Separated Values)
  • union: set union of the sub-arrays.

Array join

  • join: enhances #join with optional prefix, suffix, and infix.
  • joinprefixsuffix: join with a prefix and suffix.
  • joinprefixsuffix_infix: join with a prefix, suffix, and infix.

Class

  • publicize_methods: make all methods public for a block, e.g. to unit test private methods

CSV

  • http_headers: provides web file download headers for text/csv content type and disposition.

Date

  • agedays, ageyears
  • between: a random date between two specified dates
  • to_sql: date as a string formatted as expected for MySQL
  • weekday?, weekend?: is date a weekday or on the weekend

Enumerable

  • cartesian_product: return an array of all possible ordered tuples from arrays.
  • hash_by: convert the object to a hash by mapping each item to a key=>value pair.
  • index_by: convert the object to a hash by mapping each item to a key=>item pair.
  • join: forwards to self.to_a.join
  • to_h: convert the object to a hash by mapping each item to a key=>value pair.
  • tohmerge: to_h and merge any duplicate keys.
  • power_set: return an array with all subsets of the enum's elements

Enumerable map

  • map_id: return the id of an Enumerable object; requires that the object respond to an 'id' message
  • maptoa, maptof, maptoi, maptos, maptosym: convert each object to a specific type by calling its respective method toa, toi, tof, tos, to_sym
  • mapwithindex: for each item, yield to a block with the item and its incrementing index

Enumerable nitems

  • nitems_while: the number of leading elements for which block is truthy.
  • nitems_until: the number of leading elements for which block is falsey.
  • nitemswithindex: the number of leading elements for which block with index is truthy.

Enumerable select

  • select_while: return an array of the leading elements for which block is truthy.
  • select_until: return an array of the leading elements for which block is falsey.
  • selectwithindex: return an array of the leading elements for which block with index is truthy.

File

  • File.joindir: wrapper for File.join(File.dirname(...),string,...)

Fixnum

  • even?: is the number even?
  • odd?: is the number odd?

Hash

  • size?: return true if hash has any keys
  • sortbykeys: return a new Hash sorted by keys
  • each_sort: sort the keys then call each
  • each_key!: pass each key to a block; update hash in place with changes.
  • each_pair!: pass each key value pair to a block; update hash in place with changes.
  • each_value!: pass each value to a block; update hash in place with changes.
  • map_key: map each key-value pair's key by calling a a block
  • map_pair: map each key-value pair by calling a a block
  • map_value: map each key-value pair by calling a a block
  • merge_recurse: merge two hashes plus recurse whenever a key is a hash.
  • pivot: aggregates subtotals by keys and values, such as a rollup and rolldown
  • yield_pair: yield each key-value pair by calling a a block

Integer

  • rbit: reverse bit
  • maps: syntactic sugar to yield n times to a block, returning an array of any results
  • odd?: is the number odd?

IO

  • readrow: reads a row line as with IO#readline, and return the row split it into fields
  • IO.readrows: reads a file and splits text to rows and fields as a 2D array.

Kernel

  • mymethodname: return the name of the current method
  • callermethodname: return the name of the caller method, or the Nth parent up the call stack.

Math

  • ln(x): natural log of x
  • logn(x,b): log of x in base b

NilClass

  • blank?: return true (same as Rails)

Numeric

  • if: return 0 if the passed flag is any of: nil, false, 0, [], {} and otherwise return self
  • unless: return 0 unless the passed flag is any of: nil, false, 0, [], {} and otherwise return self
  • percent: return the number as a percentage with optional rounding to decimal points
  • floor_precision: return the number truncated to a given precision, i.e. decimal points

Object

  • in?: return boolean indicating whether the object is a member of the specified array parameter

Process

Extensions that help debug Ruby programs.

  • (class) ps: output of the system 'ps' command, also including aliases, as raw plain text.
  • (class) pss: output of the system 'ps' command as a hash with each value set to the right type, e.g., integer, float, etc..

REXML::Attributes

  • hash: flattens the attributes hash set into a more useful ruby hash, e.g. {:height => 100, :width => 400 }

REXML::Document

  • remove_attributes: remove all the attributes from the document's elements

REXML::Element

  • remove_attributes: remove all the attributes from the element

String

  • capitalize_words (alias to titleize/titlecase): ensures the first character of each word is uppercase.
  • decrement: decrease the rightmost natural number, with step option.
  • increment: increase the rightmost natural number, with step option.
  • lorem: return a short random string, good for use in "lorem ipsum" sample text.
  • lowcase: translate a string to lowercase, digits and single underscores (e.g. to a method name)
  • prev/pred: previous string ("b" => "a", "bbc" => "bbb", "a" => "z", "880" => "879")
  • prev!/pred!: updates variable to the previous string in place (astring = "bbc", astring.prev!, puts astring => "bbb")
  • (class) prevchar/predchar: return the previous character, with a changed flag and carry flag; that is, there are three returned values, a string and two booleans.
  • split_tab: split the string into an array at each embedded tab ("Last\tFirst\tMiddle" => ["last","first","middle"])
  • split_tsv: split the string into an array at each embedded newline and embedded tab ("A\tB\t\C\nD\tE\tF" => [["A","B","C"],["D","E","F"]])
  • to_class: the global class reference of a given string
  • words: split the string into an array of words

Symbol

  • <=> and include the comparable mixin to compare symbols as strings

Time

  • (class) stamp: current time in UTC as a timestamp string ("YYYYMMDDHHMMSS")
  • to_sql: time as a string formatted as expected for MySQL

YAML

  • (class) load_dir: specify directory patterns and pass each YAML file in the matching directories to a block; see Dir#glob for pattern details.
  • (class) loaddirpairs: specify directory patterns and pass each YAML file in the matching directories to a block to process key/value pairs.

Owner

  • Name: SixArm
  • Login: SixArm
  • Kind: organization
  • Email: sixarm@sixarm.com
  • Location: San Francisco

SixArm Software

Citation (CITATION.cff)

cff-version: 1.2.0
title: SixArm.com → Ruby → <br> Ramp is a toolkit of Ruby extensions
message: >-
  If you use this work and you want to cite it,
  then you can use the metadata from this file.
type: software
authors:
  - given-names: Joel Parker
    family-names: Henderson
    email: joel@joelparkerhenderson.com
    affiliation: joelparkerhenderson.com
    orcid: 'https://orcid.org/0009-0000-4681-282X'
identifiers:
  - type: url
    value: 'https://github.com/SixArm/sixarm_ruby_ramp/'
    description: SixArm.com → Ruby → <br> Ramp is a toolkit of Ruby extensions
repository-code: 'https://github.com/SixArm/sixarm_ruby_ramp/'
abstract: >-
  SixArm.com → Ruby → <br> Ramp is a toolkit of Ruby extensions
license: See license file

GitHub Events

Total
Last Year

Committers

Last synced: 5 months ago

All Time
  • Total Commits: 170
  • Total Committers: 2
  • Avg Commits per committer: 85.0
  • Development Distribution Score (DDS): 0.006
Past Year
  • Commits: 1
  • Committers: 1
  • Avg Commits per committer: 1.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
Joel Parker Henderson j****l@j****m 169
Joel Parker Henderson j****l@s****m 1
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 5 months ago

All Time
  • Total issues: 0
  • Total pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Total issue authors: 0
  • Total pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 0
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 0
  • Pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
Pull Request Authors
Top Labels
Issue Labels
Pull Request Labels