Skip to content

Commit 2a717e6

Browse files
committed
Updated EG_BORDERS, EG_NUMBER_FORMAT, EG_NUMBER_FORMAT_TYPE with Eiffel to Json mapping.
1 parent 4200fd4 commit 2a717e6

File tree

5 files changed

+281
-5
lines changed

5 files changed

+281
-5
lines changed

sheets/src/objects/eg_border.e

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,23 @@
11
note
2-
description: "Summary description for {EG_BORDER}."
3-
author: ""
2+
description: "[
3+
A border along a cell.
4+
5+
JSON representation
6+
7+
{
8+
"style": enum (Style),
9+
"width": integer,
10+
"color": {
11+
object (Color)
12+
},
13+
"colorStyle": {
14+
object (ColorStyle)
15+
}
16+
}
17+
]"
418
date: "$Date$"
519
revision: "$Revision$"
20+
EIS: "name=border", "src=https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets/cells#border", "protocol=uri"
621

722
class
823
EG_BORDER

sheets/src/objects/eg_borders.e

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,5 +60,34 @@ feature -- Access
6060
right: EG_BORDER
6161
-- The right border of the cell.
6262

63+
feature -- Element Change
64+
65+
set_top (a_top: like top)
66+
do
67+
top := a_top
68+
end
69+
70+
set_bottom (a_bottom: like bottom)
71+
do
72+
bottom := a_bottom
73+
end
74+
75+
set_left (a_left: like left)
76+
do
77+
left := a_left
78+
end
79+
80+
set_right (a_right: like right)
81+
do
82+
right := a_right
83+
end
84+
85+
86+
feature -- Eiffel to JSON
87+
88+
to_json: JSON_OBJECT
89+
do
90+
create Result.make_empty
91+
end
6392

6493
end

sheets/src/objects/eg_cell_format.e

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,11 @@ feature -- Eiffel to JSON
192192
do
193193
create Result.make_empty
194194
-- TODO
195-
Result.put (Void, "numberFormat")
195+
if attached number_format as l_number_format then
196+
Result.put (l_number_format.to_json, "numberFormat")
197+
end
196198
Result.put (background_color.to_json, "backgroundColor")
197199
Result.put (background_color_style.to_json, "backgroundColorStyle")
200+
198201
end
199202
end

sheets/src/objects/eg_number_format.e

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,34 @@ feature
2424
-- Pattern string used for formatting. If not set, a default pattern based on the user's locale will be used if necessary for the given type.
2525
-- See the Date and Number Formats guide (https://developers.google.com/sheets/api/guides/formats) for more information about the supported patterns.
2626

27+
feature -- Element Change
28+
29+
set_type (a_type: like type)
30+
do
31+
type := a_type
32+
ensure
33+
type_set: type = a_type
34+
end
35+
36+
set_pattern (a_pattern: like pattern)
37+
do
38+
pattern := a_pattern
39+
ensure
40+
pattern_set: pattern = a_pattern
41+
end
42+
43+
44+
feature -- Eiffel to JSON
45+
46+
to_json: JSON_OBJECT
47+
do
48+
create Result.make_empty
49+
if attached type as l_type then
50+
Result.put (l_type.to_json, "type")
51+
end
52+
if attached pattern as l_pattern then
53+
Result.put (create {JSON_STRING}.make_from_string (l_pattern), "pattern")
54+
end
55+
end
56+
2757
end
Lines changed: 201 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,209 @@
11
note
2-
description: "Summary description for {EG_NUMBER_FORMAT_TYPE}."
3-
author: ""
2+
description: "[
3+
The number format of the cell. In this documentation the locale is assumed to be en_US, but the actual format depends on the locale of the spreadsheet.
4+
5+
Enums
6+
NUMBER_FORMAT_TYPE_UNSPECIFIED The number format is not specified and is based on the contents of the cell. Do not explicitly use this.
7+
TEXT Text formatting, e.g 1000.12
8+
NUMBER Number formatting, e.g, 1,000.12
9+
PERCENT Percent formatting, e.g 10.12%
10+
CURRENCY Currency formatting, e.g $1,000.12
11+
DATE Date formatting, e.g 9/26/2008
12+
TIME Time formatting, e.g 3:59:00 PM
13+
DATE_TIME Date+Time formatting, e.g 9/26/08 15:59:00
14+
SCIENTIFIC Scientific number formatting, e.g 1.01E+03
15+
]"
416
date: "$Date$"
517
revision: "$Revision$"
618

719
class
820
EG_NUMBER_FORMAT_TYPE
921

22+
inherit
23+
24+
EG_ENUM
25+
redefine
26+
default_create
27+
end
28+
29+
create
30+
default_create
31+
32+
feature {NONE} -- Initialization
33+
34+
default_create
35+
do
36+
Precursor
37+
set_value (number_format_type_unspecified)
38+
end
39+
40+
number_format_type_unspecified: INTEGER = 1
41+
-- The number format is not specified and is based on the contents of the cell. Do not explicitly use this.
42+
43+
text: INTEGER = 2
44+
-- Text formatting, e.g 1000.12.
45+
46+
number: INTEGER = 3
47+
-- Number formatting, e.g, 1,000.12
48+
49+
percent: INTEGER = 3
50+
-- Percent formatting, e.g 10.12%
51+
52+
currency: INTEGER = 4
53+
-- Currency formatting, e.g $1,000.12
54+
55+
date: INTEGER = 5
56+
-- Date formatting, e.g 9/26/2008
57+
58+
time: INTEGER = 6
59+
-- Time formatting, e.g 3:59:00 PM.
60+
61+
date_time: INTEGER = 7
62+
-- Date+Time formatting, e.g 9/26/08 15:59:00
63+
64+
scientific: INTEGER = 8
65+
-- Scientific number formatting, e.g 1.01E+03
66+
67+
68+
feature -- Change Elements
69+
70+
set_text
71+
do
72+
set_value (text)
73+
ensure
74+
value_set_with_text: value = text
75+
end
76+
77+
set_number
78+
do
79+
set_value (number)
80+
ensure
81+
value_set_with_number: value = number
82+
end
83+
84+
set_percent
85+
do
86+
set_value (percent)
87+
ensure
88+
value_set_with_percent: value = percent
89+
end
90+
91+
set_currency
92+
do
93+
set_value (currency)
94+
ensure
95+
value_set_with_currency: value = currency
96+
end
97+
98+
set_date
99+
do
100+
set_value (date)
101+
ensure
102+
value_set_with_date: value = date
103+
end
104+
105+
set_time
106+
do
107+
set_value (time)
108+
ensure
109+
value_set_with_time: value = time
110+
end
111+
112+
set_date_time
113+
do
114+
set_value (date_time)
115+
ensure
116+
value_set_with_time: value = date_time
117+
end
118+
119+
set_scientific
120+
do
121+
set_value (scientific)
122+
ensure
123+
value_set_with_time: value = scientific
124+
end
125+
126+
127+
feature -- Status Report
128+
129+
is_text: BOOLEAN
130+
do
131+
Result := value = text
132+
end
133+
134+
is_number: BOOLEAN
135+
do
136+
Result := value = number
137+
end
138+
139+
is_percent: BOOLEAN
140+
do
141+
Result := value = percent
142+
end
143+
144+
is_currency: BOOLEAN
145+
do
146+
Result := value = currency
147+
end
148+
149+
is_date: BOOLEAN
150+
do
151+
Result := value = date
152+
end
153+
154+
155+
is_time: BOOLEAN
156+
do
157+
Result := value = time
158+
end
159+
160+
is_date_time: BOOLEAN
161+
do
162+
Result := value = date_time
163+
end
164+
165+
is_scientific: BOOLEAN
166+
do
167+
Result := value = scientific
168+
end
169+
170+
is_valid_value (a_value: INTEGER): BOOLEAN
171+
-- Can `a_value' be used in a `set_value' feature call?
172+
do
173+
Result := a_value = number_format_type_unspecified or else
174+
a_value = text or else
175+
a_value = number or else
176+
a_value = percent or else
177+
a_value = currency or else
178+
a_value = date or else
179+
a_value = time or else
180+
a_value = date_time or else
181+
a_value = scientific
182+
end
183+
184+
185+
feature -- Eiffel to JSON
186+
187+
to_json: JSON_STRING
188+
-- Json representation of current object.
189+
do
190+
if is_text then
191+
Result := "TEXT"
192+
elseif is_number then
193+
Result := "NUMBER"
194+
elseif is_percent then
195+
Result := "PERCENT"
196+
elseif is_currency then
197+
Result := "CURRENCY"
198+
elseif is_date then
199+
Result := "DATE"
200+
elseif is_time then
201+
Result := "TIME"
202+
elseif is_date_time then
203+
Result := "DATE_TIME"
204+
else
205+
Result := "NUMBER_FORMAT_TYPE_UNSPECIFIED"
206+
end
207+
end
208+
10209
end

0 commit comments

Comments
 (0)