Socket
Book a DemoInstallSign in
Socket

post_in_fix

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

post_in_fix

0.9.0
bundlerRubygems
Version published
Maintainers
1
Created
Source

PostInFix

Parse an expression in infix format using the Infix class, and obtain a stack based notation from it (RPN). The stack output can also be converted into a Postfix object, for further translation into other forms.

The only use so far for this has been to convert infix notated Solr boost expressions into a form Solr can understand. Therefor to_solr() is the only output of the Postfix class.

Installation

Add this line to your application's Gemfile:

gem 'post_in_fix'

And then execute:

$ bundle

Or install it yourself as:

$ gem install post_in_fix

Usage

Stack from a simple expression:

infix = PostInFix::Infix.new("1+2")
infix.to_stack  # => [1, 2, OP<+>]

OP<+> here is an object of the class PostInFix::Operator

Stack from a slightly more complex expression:

infix = PostInFix::Infix.new("(33.73+9.2)*7")
infix.to_stack  # => [33.73, 9.2, OP<+>, 7, OP<*>]

Stack from an expression where variables (non-values) are included:

infix = PostInFix::Infix.new("foo/(3.2*(bar-baz))")
infix.to_stack  # => ["foo", 3.2, "bar", "baz", OP<->, OP<*>, OP</>]

Output a Solr compatible expression from that last expression:

infix = PostInFix::Infix.new("foo/(3.2*(bar-baz))")
infix.to_postfix.to_solr  # => "div(foo,product(3.2,sub(bar,baz)))"

Contributing

  • Fork it ( https://github.com/stefanberndtsson/post_in_fix/fork )
  • Create your feature branch (git checkout -b my-new-feature)
  • Commit your changes (git commit -am 'Add some feature')
  • Push to the branch (git push origin my-new-feature)
  • Create a new Pull Request

FAQs

Package last updated on 29 Nov 2015

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.