Class: Facehugger
Instance Attribute Summary collapse
-
#api_key ⇒ Object
Returns the value of attribute api_key.
-
#api_secret ⇒ Object
Returns the value of attribute api_secret.
Class Method Summary collapse
Instance Method Summary collapse
- #faces_detect(args = {}) ⇒ Object
-
#initialize(args = {:api_key => "", :api_secret => ""}) ⇒ Facehugger
constructor
A new instance of Facehugger.
- #valid? ⇒ Boolean
Constructor Details
#initialize(args = {:api_key => "", :api_secret => ""}) ⇒ Facehugger
Returns a new instance of Facehugger.
11 12 13 14 |
# File 'lib/facehugger.rb', line 11 def initialize(args = {:api_key => "", :api_secret => ""}) @api_key = args[:api_key] @api_secret = args[:api_secret] end |
Instance Attribute Details
#api_key ⇒ Object
Returns the value of attribute api_key.
9 10 11 |
# File 'lib/facehugger.rb', line 9 def api_key @api_key end |
#api_secret ⇒ Object
Returns the value of attribute api_secret.
9 10 11 |
# File 'lib/facehugger.rb', line 9 def api_secret @api_secret end |
Class Method Details
.photos(response = {}) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/facehugger.rb', line 21 def self.photos(response = {}) photos = [] if response.has_key? 'photos' response['photos'].each do |photo| photos << Face::Photo.new(photo) end end photos end |
Instance Method Details
#faces_detect(args = {}) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/facehugger.rb', line 33 def faces_detect(args = {}) response = super args return nil if response['status'] != 'success' photos = Facehugger.photos response return nil if photos.nil? photos.each do |photo| = [] photo..sort_by! do |t| t['attributes']['face']['confidence'] end.reverse.each do |tag| << Face::Tag.new(tag) end photo. = end photos end |
#valid? ⇒ Boolean
16 17 18 19 |
# File 'lib/facehugger.rb', line 16 def valid? response = account_limits response['status'] == 'success' end |