Class: Sfcc::Cim::Data

Inherits:
Object
  • Object
show all
Defined in:
lib/sfcc/data.rb,
ext/sfcc/cim_data.c

Constant Summary collapse

Good =

(0)

INT2FIX(CIMC_goodValue)
Null =

(1<<8)

INT2FIX(CIMC_nullValue)
Key =

(2<<8)

INT2FIX(CIMC_keyValue)
NotFound =

(4<<8)

INT2FIX(CIMC_notFound)
Bad =

(0x80<<8)

INT2FIX(CIMC_badValue)

Instance Method Summary collapse

Instance Method Details

#bad?Boolean

Returns:

  • (Boolean)

20
21
22
# File 'lib/sfcc/data.rb', line 20

def bad?
  state_is Bad
end

#good?Boolean

Returns:

  • (Boolean)

17
18
19
# File 'lib/sfcc/data.rb', line 17

def good?
  state_is Good
end

#key?Boolean

Returns:

  • (Boolean)

29
30
31
# File 'lib/sfcc/data.rb', line 29

def key?
  state_is Key
end

#not_found?Boolean

Returns:

  • (Boolean)

26
27
28
# File 'lib/sfcc/data.rb', line 26

def not_found?
  state_is NotFound
end

#null?Boolean

Returns:

  • (Boolean)

23
24
25
# File 'lib/sfcc/data.rb', line 23

def null?
  state_is Null
end

#stateObject

Get the state of the data


18
19
20
21
22
23
# File 'ext/sfcc/cim_data.c', line 18

static VALUE state(VALUE self)
{
  CIMCData *data;
  Data_Get_Struct(self, CIMCData, data);
  return UINT2NUM(data->state);
}

#state_is(state) ⇒ Boolean

Check the value state

Returns:

  • (Boolean)

58
59
60
61
62
63
64
65
# File 'ext/sfcc/cim_data.c', line 58

static VALUE state_is(VALUE self, VALUE state)
{
  CIMCData *data;
  Data_Get_Struct(self, CIMCData, data);
  if (data->state & FIX2INT(state))
    return Qtrue;
  return Qfalse;
}

#to_sObject


8
9
10
11
12
13
14
15
16
# File 'lib/sfcc/data.rb', line 8

def to_s
  state = if good? then "good"
elsif bad? then "bad"
elsif null? then "null"
elsif not_found? then "not found"
elsif key? then "key"
else "???" end
  "<#{state}>[#{type}]: #{value}"
end

#typeCim::Type

Get the type of the data

Returns:


31
32
33
34
35
36
# File 'ext/sfcc/cim_data.c', line 31

static VALUE type(VALUE self)
{
  CIMCData *data;
  Data_Get_Struct(self, CIMCData, data);
  return Sfcc_wrap_cim_type(data->type);
}

#valueObject

Get the value of the data


44
45
46
47
48
49
# File 'ext/sfcc/cim_data.c', line 44

static VALUE value(VALUE self)
{
  CIMCData *data;
  Data_Get_Struct(self, CIMCData, data);
  return sfcc_cimdata_to_value(data, Qnil);
}