Class: Mindee::V1::Parsing::Standard::DateField

Inherits:
BaseField show all
Defined in:
lib/mindee/v1/parsing/standard/date_field.rb

Overview

Represents a date.

Instance Attribute Summary collapse

Attributes inherited from BaseField

#reconstructed

Attributes inherited from AbstractField

#bounding_box, #confidence, #page_id, #polygon

Instance Method Summary collapse

Methods inherited from AbstractField

array_confidence, array_sum, float_to_string, #to_s

Constructor Details

#initialize(prediction, page_id) ⇒ DateField

Returns a new instance of DateField.

Parameters:

  • prediction (Hash)
  • page_id (Integer, nil)


28
29
30
31
32
33
34
35
# File 'lib/mindee/v1/parsing/standard/date_field.rb', line 28

def initialize(prediction, page_id)
  super
  @is_computed = prediction['is_computed']
  return unless @value

  @date_object = Date.parse(@value)
  @raw = prediction['raw']
end

Instance Attribute Details

#date_objectDate? (readonly)

The date as a standard Ruby Date object.

Returns:

  • (Date, nil)


15
16
17
# File 'lib/mindee/v1/parsing/standard/date_field.rb', line 15

def date_object
  @date_object
end

#is_computedbool? (readonly)

Whether the field was computed or retrieved directly from the document.

Returns:

  • (bool, nil)


24
25
26
# File 'lib/mindee/v1/parsing/standard/date_field.rb', line 24

def is_computed
  @is_computed
end

#rawString? (readonly)

The textual representation of the date as found on the document.

Returns:

  • (String, nil)


21
22
23
# File 'lib/mindee/v1/parsing/standard/date_field.rb', line 21

def raw
  @raw
end

#valueString? (readonly)

The ISO 8601 representation of the date, regardless of the raw contents.

Returns:

  • (String, nil)


18
19
20
# File 'lib/mindee/v1/parsing/standard/date_field.rb', line 18

def value
  @value
end