Module: Arduino::Library::InstanceMethods

Included in:
Finder, Model
Defined in:
lib/arduino/library/instance_methods.rb

Overview

These are the DSL methods that can be imported by requiring ‘arduino/library/include’

Instance Method Summary collapse

Instance Method Details

#db_defaultObject



14
15
16
# File 'lib/arduino/library/instance_methods.rb', line 14

def db_default
  DefaultDatabase.instance
end

#db_from(file_or_url) ⇒ Object

Parameters:

  • file_or_url (String)

    — either a local file, or URL, can be gzipped



10
11
12
# File 'lib/arduino/library/instance_methods.rb', line 10

def db_from(file_or_url)
  Database.new(file_or_url)
end

#library_from(file_or_url) ⇒ Object

file_or_url can be a JSON file name, a .properties file name, or a URL to either of the above.

Parameters:

  • file_or_url (String)


23
24
25
# File 'lib/arduino/library/instance_methods.rb', line 23

def library_from(file_or_url)
  Arduino::Library::Model.from(file_or_url)
end

#search(database = db_default, **opts) ⇒ Object

opts is a Hash that you can use to pass attributes with values, any number of them. All matching results are returned as models.

name: 'AudioZero'
author: /konstantin/i              - regexp supported
architectures: [ 'avr' ]           - array is matched if it's a subset
version: proc do |value|           — or a proc for max flexibility
  value.start_with?('1.') )
end

Parameters:

  • database (Database) (defaults to: db_default)

    db instance (or skip it to use the default)

  • opts (Hash)

    hash of attribute names and values to match



40
41
42
43
# File 'lib/arduino/library/instance_methods.rb', line 40

def search(database = db_default, **opts)
  Arduino::Library::Model.database = database
  database.search(**opts)
end