Class: Filemaker::Resultset
- Inherits:
-
Object
- Object
- Filemaker::Resultset
- Includes:
- Enumerable
- Defined in:
- lib/filemaker/resultset.rb
Instance Attribute Summary collapse
-
#count ⇒ Integer
readonly
Number of records.
-
#date_format ⇒ String
readonly
Ruby’s date format directive.
-
#fields ⇒ Hash
readonly
Representing the top-level non-portal field-definition.
-
#list ⇒ Array
readonly
Hold records.
-
#params ⇒ Hash
readonly
The request params.
-
#portal_fields ⇒ Hash
readonly
Representing the portal field-definition.
-
#server ⇒ Filemaker::Server
readonly
The server.
-
#time_format ⇒ String
readonly
Ruby’s time format directive.
-
#timestamp_format ⇒ String
readonly
Ruby’s date and time format directive.
-
#total_count ⇒ Integer
readonly
Total count of the record.
-
#xml ⇒ String
readonly
The raw XML for inspection.
Instance Method Summary collapse
-
#each(*args, &block) ⇒ Object
Delegate to list -> map, filter, reverse, etc.
-
#initialize(server, xml, params = nil) ⇒ Resultset
constructor
A new instance of Resultset.
- #size ⇒ Object (also: #length)
Constructor Details
#initialize(server, xml, params = nil) ⇒ Resultset
Returns a new instance of Resultset.
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/filemaker/resultset.rb', line 44 def initialize(server, xml, params = nil) @list = [] @fields = {} @portal_fields = {} @server = server @params = params # Useful for debugging doc = Nokogiri::XML(xml).remove_namespaces! @xml = doc.to_xml(indent: 2) # Just want to pretty print it error_code = doc.xpath('/fmresultset/error').attribute('code').value.to_i raise_potential_error!(error_code) datasource = doc.xpath('/fmresultset/datasource') = doc.xpath('/fmresultset/metadata') resultset = doc.xpath('/fmresultset/resultset') records = resultset.xpath('record') @date_format = convert_format(datasource.attribute('date-format').value) @time_format = convert_format(datasource.attribute('time-format').value) @timestamp_format = \ convert_format(datasource.attribute('timestamp-format').value) @count = resultset.attribute('count').value.to_i @total_count = datasource.attribute('total-count').value.to_i () build_records(records) end |
Instance Attribute Details
#count ⇒ Integer (readonly)
Returns number of records.
12 13 14 |
# File 'lib/filemaker/resultset.rb', line 12 def count @count end |
#date_format ⇒ String (readonly)
Returns Ruby’s date format directive.
24 25 26 |
# File 'lib/filemaker/resultset.rb', line 24 def date_format @date_format end |
#fields ⇒ Hash (readonly)
Returns representing the top-level non-portal field-definition.
18 19 20 |
# File 'lib/filemaker/resultset.rb', line 18 def fields @fields end |
#list ⇒ Array (readonly)
Returns hold records.
9 10 11 |
# File 'lib/filemaker/resultset.rb', line 9 def list @list end |
#params ⇒ Hash (readonly)
Returns the request params.
36 37 38 |
# File 'lib/filemaker/resultset.rb', line 36 def params @params end |
#portal_fields ⇒ Hash (readonly)
Returns representing the portal field-definition.
21 22 23 |
# File 'lib/filemaker/resultset.rb', line 21 def portal_fields @portal_fields end |
#server ⇒ Filemaker::Server (readonly)
Returns the server.
33 34 35 |
# File 'lib/filemaker/resultset.rb', line 33 def server @server end |
#time_format ⇒ String (readonly)
Returns Ruby’s time format directive.
27 28 29 |
# File 'lib/filemaker/resultset.rb', line 27 def time_format @time_format end |
#timestamp_format ⇒ String (readonly)
Returns Ruby’s date and time format directive.
30 31 32 |
# File 'lib/filemaker/resultset.rb', line 30 def @timestamp_format end |
#total_count ⇒ Integer (readonly)
Returns total count of the record.
15 16 17 |
# File 'lib/filemaker/resultset.rb', line 15 def total_count @total_count end |
#xml ⇒ String (readonly)
Returns the raw XML for inspection.
39 40 41 |
# File 'lib/filemaker/resultset.rb', line 39 def xml @xml end |
Instance Method Details
#each(*args, &block) ⇒ Object
Delegate to list -> map, filter, reverse, etc
75 76 77 |
# File 'lib/filemaker/resultset.rb', line 75 def each(*args, &block) list.each(*args, &block) end |
#size ⇒ Object Also known as: length
79 80 81 |
# File 'lib/filemaker/resultset.rb', line 79 def size list.size end |