Class: YuiRestClient::Widgets::Timefield

Inherits:
Base
  • Object
show all
Defined in:
lib/yui_rest_client/widgets/timefield.rb

Overview

Class representing a DateField in the UI, namely YTimeField.

Instance Method Summary collapse

Methods inherited from Base

#action, #collect_all, #debug_label, #enabled?, #exists?, #initialize, #property

Methods included from YuiRestClient::Waitable

#wait_until, #wait_while

Constructor Details

This class inherits a constructor from YuiRestClient::Widgets::Base

Instance Method Details

#set(time) ⇒ Timefield

Sends action to set the value of time field. Accepts Time or DateTime object and sets value in ISO 8601 format HH:MM:SS.

Examples:

Set current time in the time field with id ‘test’ using Time

app.timefield(id: 'time').set(Time.now)

Set custom time in the field with id ‘test’ to 04:05:06

app.timefield(id: 'time').set(DateTime.new(2001,2,3,4,5,6))

Parameters:

  • time (Time)

    time to be set in the time field

Returns:

  • (Timefield)

    in case action is successful

Raises:

  • YuiRestClientError if parameter is not DateTime or Time



16
17
18
19
20
21
22
23
# File 'lib/yui_rest_client/widgets/timefield.rb', line 16

def set(time)
  unless  [DateTime, Time].any? { |c| time.is_a? c }
    raise Error::YuiRestClientError, 'Parameter is not Date, Time or DateTime'
  end

  action(action: Actions::ENTER_TEXT, value: time.strftime('%T'))
  self
end

#valueString

Returns text that is currently set for timefield. Gets value from ‘value’ parameter in JSON representation of YTimeField.

Examples:

Get value from timefield with id “time”

{
    "class" : "YTimeField",
    "debug_label" : "Time:",
    "hstretch" : true,
    "id" : "time",
    "label" : "&Time:",
    "notify" : true,
    "value" : "20:15:00"
}
app.timefield(id: 'time').value # '20:15:00'

Returns:

  • (String)

    value



40
41
42
# File 'lib/yui_rest_client/widgets/timefield.rb', line 40

def value
  property(:value)
end