New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

basic_tree

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

basic_tree

  • 1.0.3
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

= BasicTree

A basic Ruby tree structure with nice syntax.

== Example

fruit = BasicTree.new "Fruit" do add "Apple" do add "Red Delicious" end add "Banana" do add "Manzano" add "Plantain" end add "Orange" end

fruit.object

"Fruit"

banana = fruit.get(2) # get the 2nd fruit banana.object # "Banana"

plantain = banana.get(2) # get the 2nd banana plantain.object # "Plantain"

plantain.parent.object # "Banana"

plantain.path.map(&:object)

["Fruit", "Banana", "Plantain"]

plantain.ancestors.map(&:object) # ancestors is like path except it doesn't include itself

["Fruit", "Banana"]

banana.subtree.map(&:object)

["Banana", "Manzano", "Plantain"]

fruit.descendants.map(&:object) # descendants is like subtree except it doesn't include itself

["Apple", "Red Delicious", "Banana", "Manzano", "Plantain", "Orange"]

banana.siblings.map(&:object)

["Apple", "Orange"]

plantain.root.object # "Fruit"

plantain.level # 3

banana.root? # false

fruit.root? # true

banana.leaf? # false

plantain.leaf? # true

== Note on Patches/Pull Requests

  • Fork the project.
  • Make your feature addition or bug fix.
  • Add tests for it. This is important so I don't break it in a future version unintentionally.
  • Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
  • Send me a pull request. Bonus points for topic branches.

== Copyright

See LICENSE for details.

FAQs

Package last updated on 25 May 2011

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

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc