Module: OpenKVK
- Extended by:
- Configuration
- Defined in:
- lib/openkvk.rb,
lib/openkvk/api.rb,
lib/openkvk/version.rb,
lib/openkvk/configuration.rb
Defined Under Namespace
Modules: Configuration Classes: API, InvalidResponseException
Constant Summary collapse
- VERSION =
"0.0.8"
Constants included from Configuration
Configuration::DEFAULT_HOST, Configuration::VALID_OPTIONS_KEYS
Class Method Summary collapse
- .find(options = {}) ⇒ Object
- .find_by_bedrijfsnaam(name, options = {}) ⇒ Object
- .search(keywords) ⇒ Object
Methods included from Configuration
configure, extended, options, reset
Class Method Details
.find(options = {}) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/openkvk.rb', line 14 def find(={}) if .is_a?(String) = {:conditions => ["bedrijfsnaam LIKE '%#{}%'", "bedrijfsnaam LIKE '%#{.to_s.upcase}%'", "bedrijfsnaam LIKE '%#{capitalize_and_format_each_word()}%'"], :match_condition => :any} end = {:limit => 1000, :select => ["*"], :count => :all, :match_condition => :all}.merge() [:limit] = 1 if [:count] == :first result = API.query("SELECT #{[:select].join(", ")} FROM kvk WHERE #{[:conditions].join([:match_condition] == :any ? " OR " : " AND ")} LIMIT #{[:limit]}") return result.first if [:count] == :first result end |
.find_by_bedrijfsnaam(name, options = {}) ⇒ Object
26 27 28 29 30 |
# File 'lib/openkvk.rb', line 26 def find_by_bedrijfsnaam(name, ={}) # bedrijfsnaam is always a string, so we want to search for different formats of the string = {:conditions => ["bedrijfsnaam LIKE '%#{name}%'", "bedrijfsnaam LIKE '%#{name.to_s.upcase}%'", "bedrijfsnaam LIKE '%#{capitalize_and_format_each_word(name)}%'"], :match_condition => :any}.merge() find() end |