Socket
Book a DemoInstallSign in
Socket

joinable_array

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

joinable_array

0.0.1
bundlerRubygems
Version published
Maintainers
1
Created
Source

JoinableArray

A small gem to make it easier to do relational joins with arrays in ruby without requiring database calls.

Installation

Add this line to your application's Gemfile:

gem 'joinable_array'

And then execute:

$ bundle

Or install it yourself as:

$ gem install joinable_array

Usage

joinable_array offers a JoinableArray class which can be used as

things1 = JoinableArray(array1)
things2 = JoinableArray(array2)

outer_join = things1
  .outer_join(things2) {|l,r| l.merge(r)}

inner_join = things1
  .joins_on {|x| [x[0], x[1]]}
  .inner_join(things2.joins_on {|x| [x.a, x.b]}) {|l,r| l.merge(r)}
 
left_join = things1
  .joins_on {|x| [x[0], x[1]]}
  .fills_with {|key| key[0 .. -1].concat([0,0,0])}
  .left_join(things2.joins_on {|x| [x.a, x.b]}) {|l,r| l.merge(r)}
 
right_join = things1
  .joins_on {|x| [x[0], x[1]]}
  .right_join(things2
    .joins_on {|x| [x.a, x.b]}
    .fills_with {|key|, Obj.new(*key)}
  ) {|l,r| l.merge(r)}

The simplest join is outer_join which is a method on JoinableArray and requires another JoinableArray as its parameter and returns a 3rd JoinableArray which is the outer join of the original two JoinableArray instances. The elements of the returned JoinableArray is defined by the block passed to outer_join. The block accepts two parameters: the first is an element from the first JoinableArray and the second is from the other JoinableArray. The block returns the value of resulting JoinableArray

FAQs

Package last updated on 12 Aug 2013

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.